1. 程式人生 > >實驗三 表資料的插入、修改和刪除

實驗三 表資料的插入、修改和刪除

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;