I have a question I'd like to help me solve, it's about the values of the data type in the fields of the database.
- It is mandatory to specify the number of characters or values that will have a field identifier id INT.
id INT UNSIGNED NOT NULL AUTO_INCREMENT
- What is the difference between id INT and id INT(11), It is mandatory to establish a number of values?.
id INT UNSIGNED NOT NULL AUTO_INCREMENT
id(11) INT UNSIGNED NOT NULL AUTO_INCREMENT
-
What is the default setting MySQL in id INT, if not specify any value?
-
What is the maximum amount exact numbers that allows me to add INT
-
In that case you must use INT
-
In that case you should use BIGINT
Example: I will take an example of a news portal, that I could receive many visits.
Need to record the number of times it is accessed worldwide news, let's say your news year is visited 999.999.999 times, is a bit exaggerated know :), but it is valid to use in this case INT or BIGINT
I much appreciate your support.
Best Answer
According to Numeric Type Attributes:
And according to Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT:
The datatype
INT
uses 4 bytes (from-2147483648
to2147483647
or unsigned from0
to4294967295
), the datatypeBIGINT
uses 8 bytes (from-9223372036854775808
to9223372036854775807
or unsigned from0
to18446744073709551615
).So the answers to your questions in my opinion are:
Ad 3) No display width will be specified.Ad 3) The display with will be set to the default value for datatype
INT
. That is 10 for unsigned and 11 for signed (signed has more to allow space for a leading dash character, the minus sign, for negative values).Thanks spencer7593 for the correction.
Ad 4) See above.
2147483647
you can useINT
, above that value you can must either use unsignedINT
orBIGINT
.