实验三 表数据的插入、修改和删除

1、  打开数据库YGGL;

Use yggl;

2、  向Employees表中插入一条记录:000001 王林 大专 1966-01-23  1  8  中山路32-1-508  83355668  2;

Insert  into  employees  values (

‘000001’,’王林’,’大专’,’1966-1-23’,’1’,8,’中山路32-1-508’,’83355668’,’2’);

3、  向Employees表中插入一条记录:其中员工编号为010008,姓名伍容华,学历本科,出生日期1976-03-28,性别男,部门号1;

Insert  into  employees  values (

‘010008’,  ’伍容华’,  ’本科’, ’ 1976-03-28’, ’1’,3,’北京东路100-2’,’833211321’,’1’);

4、  使用界面工具将Departments表和Salary表中的数据输入,将Employees表中的前4条记录插入;

5、  删除Salary表中编号为102201的工资信息;

Delete  from  employees where employeeid=’102201’;

6、  使用insert…set向Salary表中添加记录:000001  2100.8  123.09;

Insert into salary  set employeeid=’000001’,income=2100.8,outcome=123.09;

7、  使用replace向Departments中添加记录:5  广告部  负责产品推广;

Replace into departments values (‘5’,’广告部’,’负责推广产品’);

8、  复制新表Departments1,要求结构与Departments表相同;

Create table departments1 like departments;

9、  复制新表Salary1,要求数据与Salary相同;

Create table salary1 as (select  *  from  salary);

.

10、  修改表employees,将编号为020018的部门号修改为4;

Update  employees

Set departmentid=4

Where employeeid = ’020018’ ;

11、  将所有职工的工资收入增加500元;

Update  salary

Set income=income+500;

12、  使用多表修改将“张石兵”的工资收入增加500元;

Update  salary,employees

Set income=income+500

Where name=’ 张石兵’;

13、  使用多表删除将“王林”的工资信息删除;

Delete salary,employees

From salaryemployees

Where name=’ 王林’;

14、  使用truncate table删除Salary表中的所有行。

Truncate table salary;

猜你喜欢

转载自www.cnblogs.com/lvwuwa/p/10165504.html