Counting is numerical, and are integer and positive values.
The appropriate type for this, therefore, is INTEGER UNSIGNED
(whole WITHOUT sign). In this family, we have these possibilities:
TIPO BYTES SIGNED UNSIGNED
=========== ======= ============================= =====================
TINYINT 1 de -128 a 127 de 0 a 255
SMALLINT 2 de -32768 a 32767 de 0 a 65535
MEDIUMINT 3 de -8388608 a 8388607 de 0 a 16777215
INT 4 de -2147483648 a 2147483647 de 0 a 4294967295
BIGINT 8 de -2^63 a 2^63-1 de 0 a 2^64-1
Choose the type that best suits your case, providing the maximum number you want to store.
More details in the manual:
https://dev.mysql.com/doc/refman/5.7/en/integer-types.html
The person who negatived, could you at least say the reason? After all it is a doubt that refers to programming.
– user24136
If I understood correctly you want to store the total views, ie a number. Why the column would not be
bigint
?– rLinhares
Hello rLinhares. Right. She would accept the sum of each access? Ie. At each access, I would have to add + 1, because I never used this type.
– user24136
If you want to calculate (sum / subtraction and etc) a value, it must be in a numerical column and not in a
VARCHAR
, as mentioned by @rLinhares the right isbigint
,Integer
or any on the same line.– Andrey
Right. I’ll take your cue. Thank you all.
– user24136
Yes, it’s a numerical field, would be no problem
– rLinhares
Ask a forced "bit", perhaps it would be better to add/ask the disadvantages in using a
varchar
instead of aint
– lazyFox