Not null tinyint and AUTO_INCREMENT
mysql>
mysql> CREATE TABLE Item(
-> title_num TINYINT NOT NULL AUTO_INCREMENT,
-> title_cust CHAR(4),
-> PRIMARY KEY(title_num)
-> ) ;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> DESC Item;
+------------+------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+------------+------+-----+---------+----------------+
| title_num | tinyint(4) | NO | PRI | NULL | auto_increment |
| title_cust | char(4) | YES | | NULL | |
+------------+------------+------+-----+---------+----------------+
2 rows in set (0.00 sec)
mysql>
mysql>
mysql> INSERT INTO Item VALUES
-> (1, 'Mr.'),
-> (2, 'Ms.'),
-> (3, 'Mrs.'),
-> (4, 'Miss'),
-> (5, 'Sir'),
-> (6, 'Dame'),
-> (7, 'Dr.'),
-> (8, 'Lady'),
-> (9, 'None');
Query OK, 9 rows affected (0.00 sec)
Records: 9 Duplicates: 0 Warnings: 0
mysql>
mysql>
mysql> drop table Item;
Query OK, 0 rows affected (0.00 sec)
mysql>
Related examples in the same category