INT4
INT4 is a data type in SQL that allows the storage of whole numbers, which can be both positive or negative. It is a 4-byte size variant of INT, meaning it can store numerical values from -2147483648 to 2147483647.
Example
Output
Explanation
This demonstrates the creation of a table named ‘test’ with one column ‘id’ of INT4 type, insert a value into it and then retrieve that value. INT4 is a 4-byte integer data type in PostgreSQL.
Example
Output
Explanation
The code block declares a variable @MyVariable
as INT
type and sets it to the number 10. Then, we use SELECT
statement to output the value of the @MyVariable
, which is labeled as ‘INT4’.
Example
Output
Explanation
In this example, a new table named ‘employees’ is created with three columns: ID, NAME, and BIRTHDATE. INT(4) is used to declare the ID column, which only allows up to four digits. A new record is inserted into the table, with the value 1234 in the ID field, demonstrating that the INT(4) declaration allows for this four digit integer. The output shows the result of a SELECT * FROM employees query, confirming that the new record has been successfully inserted.