SMALLINT
SMALLINT is a numeric data type in SQL. It's used to store integers, but with less storage size compared to other integer data types. SMALLINT values are whole numbers, and their range and precision may vary between different SQL databases. The typical range is from -32768 to 32767.
Example
Output
Query OK, 0 rows affected (0.01 sec)
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
Output
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
Output
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
Output
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
Output
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.