INT4
Example
Section titled “Example”CREATE TABLE test ( id INT4);INSERT INTO test (id) VALUES (1234);SELECT * FROM test;Output
Section titled “Output” id----- 1234Explanation
Section titled “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
Section titled “Example”DECLARE @MyVariable INT;SET @MyVariable = 10;SELECT @MyVariable AS 'INT4';Output
Section titled “Output”INT410Explanation
Section titled “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
Section titled “Example”CREATE TABLE employees ( ID INT(4), NAME VARCHAR(20), BIRTHDATE DATE);
INSERT INTO employees (ID, NAME, BIRTHDATE) values (1234, 'John', TO_DATE('1990/01/01','YYYY/MM/DD'));Output
Section titled “Output”SELECT * FROM employees;
ID | NAME | BIRTHDATE-----|--------|-----------1234 | John | 01-JAN-90Explanation
Section titled “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.