INT
INT is a datatype in SQL that is used to store integer values. It can store both positive and negative numbers. The storage size of INT is 4 bytes and its range goes from -2,147,483,648 to 2,147,483,647.
Example
Output
Explanation
In the example above, an Employees
table is created with the EmployeeID
column of INT
data type, and the FirstName
and LastName
columns of VARCHAR
data type. One new record is inserted into the Employees
table where the EmployeeID
is 1
, the FirstName
is John
and the LastName
is Doe
. The *
in the SELECT
statement indicates that all rows of the Employees
table are displayed in the output.
Example
Output
Explanation
In the above example, an Employees
table is created with two columns: ID
and NAME
. The ID
column is declared as INT
to hold integer values representing the unique identifiers for each record. A record is inserted into the table with ID
being 1
and NAME
being John Doe
. The final SELECT
statement displays all records in the Employees
table where the ID
is an integer.
Example
Output
Explanation
In the example, we declare a variable ‘@TestINT’ of INT type and assign it a value of 20. The SELECT statement is then used to output the value of ‘@TestINT’, which is 20.
Example
Output
Explanation
The data type INT
is used for integer values. In the example, ID
is a data column with the integer (INT
) data type. It stores the primary key for each record in the Person
table. After the table is successfully created, we insert one row with the ID value of 1.
Example
Output
Explanation
In the example code, a table called ‘Employees’ is created with three columns: ID, Name, and Age. The INT data type is used for both the ID, which is declared as the primary key, and the Age. Then, an employee with ID 1, name ‘John Doe’, and age 32 is inserted into the table. The final command selects and outputs all records from the ‘Employees’ table.