SMALLINT[(M)] [UNSIGNED] [ZEROFILL] : SMALLINT « Data Types « MySQL Tutorial






A small integer.

The signed range is -32768 to 32767.

The unsigned range is 0 to 65535.

mysql>
mysql> CREATE TABLE myTable
    -> (
    ->    ID SMALLINT(4) UNSIGNED ZEROFILL,
    ->    Quantity INT UNSIGNED
    -> );
Query OK, 0 rows affected (0.05 sec)

mysql>
mysql> desc myTable;
+----------+-------------------------------+------+-----+---------+-------+
| Field    | Type                          | Null | Key | Default | Extra |
+----------+-------------------------------+------+-----+---------+-------+
| ID       | smallint(4) unsigned zerofill | YES  |     | NULL    |       |
| Quantity | int(10) unsigned              | YES  |     | NULL    |       |
+----------+-------------------------------+------+-----+---------+-------+
2 rows in set (0.02 sec)

mysql>
mysql> drop table myTable;
Query OK, 0 rows affected (0.00 sec)








10.20.SMALLINT
10.20.1.SMALLINT[(M)] [UNSIGNED] [ZEROFILL]
10.20.2.Insert value to SMALLINT column
10.20.3.Set up default value for SMALLINT
10.20.4.Use SMALLINT column as the primary key column