user889349 user889349 - 2 months ago 8
MySQL Question

Mysql - right data field type for list of integers

I want to store a set of integers in my column (ids_set):

id ids_set
1 1,2,3,4...76
2 4,5,8...12


What is a best field type for this - varchar or text?
Thanks.

Answer

Is better not store int separed by comma ..anyway depend of the lenght of your string ... below 255 char varchar, above is better text

see http://dev.mysql.com/doc/refman/5.7/en/storage-requirements.html

http://dev.mysql.com/doc/refman/5.7/en/char.html

char - varchar The length can be any value from 0 to 255.

BLOB, TEXT   2^16