INT2
INT2 is a small integer data representation in SQL. It uses 2 bytes of storage and can store numbers in the range from -32,768 to 32,767.
Example
Output
Explanation
In this example, a table named test_table
is created with two columns: id
and small_number
. The data type of id
is INT
(Integer), while small_number
is INT2
. An insertion is then performed into test_table
where id
is 1
and small_number
is 10
. The SELECT
statement retrieves and displays the data from the table, as indicated in the output.
In PostgreSQL, INT2
is used for storing small integers, with a size of two bytes and a range of -32768 to +32767
.
Example
Output
Explanation
The INT2
data type is used to store small integer values in SQLite. In the above code, a new table Student
is created with ID
as INT2
and Name
as TEXT
. After that, a row is inserted into Student
using the INSERT
statement. When querying the data with SELECT
, it displays the inserted row.