INSERT INTO employees(first_name,last_name)VALUES('John','Doe'), ('Mary','Jane');
第二步,从employees表中查询选择数据:
mysql>SELECT*FROM employees;+--------+------------+-----------+| emp_no | first_name | last_name |+--------+------------+-----------+| 1 | John | Doe || 2 | Mary | Jane |+--------+------------+-----------+2rowsinset
第三步,删除emp_no为2的第二个员工信息:
mysql>DELETEFROM employeesWHERE emp_no =2;Query OK, 1row affectedmysql>SELECT*FROM employees;+--------+------------+-----------+| emp_no | first_name | last_name |+--------+------------+-----------+| 1 | John | Doe |+--------+------------+-----------+1rowinset
第四步,插入新员工,并查询最后一位员工信息(emp_no):
mysql>INSERT INTO employees(first_name,last_name)VALUES('Jack','Lee');Query OK, 1row affectedmysql>SELECT*FROM employees;+--------+------------+-----------+| emp_no | first_name | last_name |+--------+------------+-----------+| 1 | John | Doe || 3 | Jack | Lee |+--------+------------+-----------+2rowsinset
mysql>UPDATE employeesSET first_name ='Joe', emp_no =10WHERE emp_no =3;Query OK, 1row affectedRowsmatched: 1 Changed: 1 Warnings: 0mysql>SELECT*FROM employees;+--------+------------+-----------+| emp_no | first_name | last_name |+--------+------------+-----------+| 1 | John | Doe || 10 | Joe | Lee |+--------+------------+-----------+2rowsinset
上面步骤中,将序列号更新为10。
第六,插入新员工数据 -
mysql>INSERT INTO employees(first_name,last_name)VALUES('Wang','Lee');Query OK, 1row affectedmysql>SELECT*FROM employees;+--------+------------+-----------+| emp_no | first_name | last_name |+--------+------------+-----------+| 1 | John | Doe || 4 | Wang | Lee || 10 | Joe | Lee |+--------+------------+-----------+