Using AUTO_INCREMENT
|
/* mysql> SELECT * FROM Employee; +----+-------+ | id | name | +----+-------+ | 1 | Joe | | 2 | Yin | | 3 | peng | | 4 | Lava | | 5 | White | | 6 | Ola | +----+-------+ 6 rows in set (0.02 sec)
*/ /* AUTO_INCREMENT : used to generate a unique identity for new rows: */ Drop table Employee;
CREATE TABLE Employee ( id MEDIUMINT NOT NULL AUTO_INCREMENT, name CHAR(30) NOT NULL, PRIMARY KEY (id) ); INSERT INTO Employee (name) VALUES ('Joe'), ('Yin'), ('peng'), ('Lava'), ('White'), ('Ola'); SELECT * FROM Employee;
|
|
|
|
|
|
|