SMALLINT
Example
Section titled “Example”CREATE TABLE Employees ( ID SMALLINT, NAME TEXT);
INSERT INTO Employees (ID, NAME) VALUES (1, 'John Doe');Output
Section titled “Output”Query OK, 0 rows affected (0.01 sec)
Explanation
Section titled “Explanation”The code creates a table Employees with two columns: ID and NAME. The ID field is a SMALLINT type, which can hold a value between -32768 and 32767. A new row is inserted into the table with ID as 1 and name as ‘John Doe’. The output indicates the query was executed successfully without affecting any previous rows.
Example
Section titled “Example”CREATE TABLE Employees ( id SMALLINT, name VARCHAR (20));
INSERT INTO Employees (id, name)VALUES (1, 'John Doe');Output
Section titled “Output”SELECT * FROM Employees; id | name----+--------- 1 | John DoeExplanation
Section titled “Explanation”In the example, a table called Employees is created with a column id of the data type SMALLINT, and a column name of the type VARCHAR. Then an entry is inserted into the Employees table with an id of 1 and a name of ‘John Doe’. The output displays the inserted data.
Example
Section titled “Example”CREATE TABLE SampleTable ( ID SMALLINT);INSERT INTO SampleTable (ID) VALUES (5), (10), (15);SELECT * FROM SampleTable;Output
Section titled “Output”ID---51015Explanation
Section titled “Explanation”In the given example, a table SampleTable is created with a single column ID of type SMALLINT. Then three values (5, 10, 15) are inserted into the ID column of SampleTable. The SELECT statement fetches all records from SampleTable. The SMALLINT data type stores whole numbers between -32768 and 32767.
Example
Section titled “Example”CREATE TABLE Employees ( ID SMALLINT, Name VARCHAR(100));
INSERT INTO Employees (ID, Name) VALUES (1, 'John Doe');INSERT INTO Employees (ID, Name) VALUES (2, 'Jane Doe');
SELECT * FROM Employees;Output
Section titled “Output”ID Name-------1 John Doe2 Jane DoeExplanation
Section titled “Explanation”In the example, a table named Employees is created with ID as a SMALLINT and Name as VARCHAR(100). After that, two rows are inserted into the table with ID and Name values. Finally, all rows from the Employees table are selected and displayed.
Example
Section titled “Example”CREATE TABLE SampleTable (ID SMALLINT);INSERT INTO SampleTable(ID) VALUES(10);SELECT * FROM SampleTable;Output
Section titled “Output”ID--10Explanation
Section titled “Explanation”This example creates a table named ‘SampleTable’ with a single column ‘ID’ of type ‘SMALLINT’. A row is inserted with an ‘ID’ of 10. The SELECT statement retrieves the contents of the ‘SampleTable’ which shows the inserted row.