I am writing an SQL query for creating a new column in a table. Part of my query includes this:
`phone` INT(8) UNSIGNED NOT NULL DEFAULT 0
The phone must have exactly 8 digits because that is how phone number works for the countries that I am working with. But I am not sure if I need to use INT(8)
or only INT
. The other way to write that portion would be:
`phone` INT UNSIGNED NOT NULL DEFAULT 0
I know for VARCHAR
for example, you specify the length. For example: VARCHAR(50)
. But in the case of INT
I am not sure, since in MySQL, it is already known that INT
can store a maximum value of 4294967295 when it is unsigned, so using INT(8)
may not make sense because INT
will always be INT
and by definition, able to store a maximum value of 4294967295 when using UNSIGNED
(https://dev.mysql.com/doc/refman/8.0/en/integer-types.html). Thank you.