INTEGER UNSIGNED AUTO_INCREMENT
mysql>
mysql> CREATE TABLE CITY_NAMES
-> (SEQNO INTEGER UNSIGNED AUTO_INCREMENT
-> NOT NULL PRIMARY KEY,
-> NAME VARCHAR(30) NOT NULL);
Query OK, 0 rows affected (0.01 sec)
mysql>
mysql> INSERT INTO CITY_NAMES VALUES (NULL, 'London')
-> ;
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO CITY_NAMES VALUES (NULL, 'New York')
-> ;
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO CITY_NAMES (NAME) VALUES ('Paris')
-> ;
Query OK, 1 row affected (0.00 sec)
mysql> SELECT * FROM CITY_NAMES;
+-------+----------+
| SEQNO | NAME |
+-------+----------+
| 1 | London |
| 2 | New York |
| 3 | Paris |
+-------+----------+
3 rows in set (0.00 sec)
mysql>
mysql>
mysql> drop table CITY_NAMES;
Query OK, 0 rows affected (0.00 sec)
Related examples in the same category