SELECT * FROM s
SELECT s.Sname,
sc.Cno,
sc.Grade
FROM
s,
sc
WHERE
s.Sno=sc.Sno
ORDER BY
sc.Grade
SELECT s.Sname,
AVG(sc.Grade)
FROM
s,
sc
WHRER
s.Sno=sc.Sno
GROUP BY
s.Sname
SELECT * FROM sc
GROUP BY
Cno
HAVING
Grade > 90
SELECT * FROM s WHRER Sno
IN (SELECT Sno FROM WHRER sc.Grade>90)
SELECT * FROM c WHRER Cname LIKE '%a%'
CREATE VIEW V_SSC (S_no,S_name,S_dept,C_no,S_Grade ) AS
SELECT s.Sno,Sname,Sdept,Cno,Grade
FROM s,sc WHRER s.Sno = sc.Sno AND
Sdept 'CS' WITH CHECK OPTION
[object Object]
SELECT * FROM V_SSC
在更新CS
系的学生时可以顺利更改
UPDATE V_SSC SET S_Grade=60 WHRER S_no='1' AND C_no='1'
涉及到了多个基本表,所以不能插入
INSERT INTO V_SSC(S_no,S_name,S_dept,C_no,S_Grade)
VALUES ('3', 'FanOne','CS','2','95')
CREATE VIEW V_S(S_no,S_name,S_dept,S_class) AS SELECT
Sno,Sname,Sdept,Class FROM s
WHRER Sdept = 'CS' WITH CHECK OPTION
SELECT * FROM v_s
INSERT INTO V_SSC(S_no,S_name,S_dept,C_no,S_Grade) VALUES ('3', 'FanOne','CS','19')
视图
基本表
插入非’CS’的时候就会报错
INSERT INTO V_SSC(S_no,S_name,S_dept,C_no,S_Grade)
VALUES ('4', 'FanOne','CSGO','19')
作者:小生凡一
链接:https://juejin.cn/post/7028107101507420190
来源:稀土掘金
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。