新建表
CREATE TABLE Teachers
(Tno CHAR(7) PRIMARY KEY,
Tname CHAR(10) NOT NULL,
Sex CHAR(2) CHECK (Sex = ‘男’ OR ‘女’),
Birthday DATE,
Dno CHAR(4),
FOREIGN KEY (Dno) REFERENCES Departments (Dno));
查询
SELECT (DISTINCT) Sno, Sname
FROM Students
WHERE Speciality LIKE ‘数据%’ OR Sname LIKE ‘李_ _’
ORDER BY Sno ASC|DESC;
SELECT MIN(Grade), MAX(Grade), AVG(Grade)
FROM SC
WHERE Cno = ‘CS302’;
SELECT Student.Sno, Sname, AVG(Grade)
FROM SC, Students
WHERE Students.Sno, = SC.Sno
GROUP BY Sno, Sname
HAVING AVG(Grade) > 85;
新增行
INSERT INTO SC (Sno, Cno)
VALUES (‘201020103’, ‘madlddd’);
删除行
DELETE FROM Students
WHERE Sno = ‘20102104’;
更新行
UPDATE Teachers
SET Title = ‘副教授’, age= ‘30’
WHERE Tno = ‘2020’;