DELETE
FROM table_name
[WHERE search_condition];
在table_name表中删除符合条件search_condition的元组
例:删除计算机系(CS)全体学生的选课记录
S(sno,sn,sd,sa) C(sno,cn,pno) SC(sno,cno,g)
DELETE
FROM SC
WHERE sno IN (
SELECT sno
FROM S
WHERE sd='CS')
INSERT
INTO tabname [(colname {, colname ...})]
VALUES (expr|NULL {, expr|NULL ...}) | subquery;
例:插入计算机系(CS)学生选修数据库(Database)课的选课记录
S(sno,sn,sd,sa) C(sno,cn,pno) SC(sno,cno,g)
INSERT INTO SC(sno,cno)
SELECT sno, cno
FROM S, C
WHERE sd='CS' and cn='Database';
UPDATE table_name
SET colname=expr|NULL|subquery,...
[WHERE search_condition]
修改指定基表table_name中满足的WHERE条件的元组
例:将计算机系学生的成绩全置零
S(sno,sn,sd,sa) C(sno,cn,pno) SC(sno,cno,g)
UPDATE SC
SET G=0
WHERE sno IN (
SELECT sno
FROM S
WHERE sd='CS');
例:将数学系学生的年龄均加1岁
UPDATE S
SET sa=sa+1
WHERE sd='math';
信息加载中,请等待
微信客服(速回)
微信客服(慢回)