Skip to content

INT2

CREATE TABLE test_table (
id INT PRIMARY KEY,
small_number INT2
);
INSERT INTO test_table VALUES (1, 10);
SELECT * FROM test_table;
id | small_number
----+-------------
1 | 10

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.