hi people i am new at php and wondering what does int(4)
mean in creating this table. thanks for helping.
CREATE TABLE mytable(
name VARCHAR (50),
age INT(4),
email VARCHAR (50)
);
hi people i am new at php and wondering what does int(4)
mean in creating this table. thanks for helping.
CREATE TABLE mytable(
name VARCHAR (50),
age INT(4),
email VARCHAR (50)
);
The code you have posted is no PHP, but a SQL statement for creating a database table called mytable
with three columns - name, age and email. The statement also has the date types of the different columns, so the database system can know how to store and retrieve them.
Int is a data type in the database - an integer (whole number).
What it means depends on the database you use - in SQL Server the 4 specifies the field precision. However, this will always be the size of an int
in SQL Server. It can holdvalues between -2,147,483,648 and 2,147,483,647.
If MySQL, it means the display width of the field.
If you are using MySQL, it is the display width of the integer. You can find this sort of information in the MySQL user manual:
For example,
INT(4)
specifies anINT
with a display width of four digits.
It depends entirely on your RDBMS: there is no standard meaning. Most will simply ignore it, or treat it as a display hint (like MySQL).