//ADD修改方式,用于增加新列或列完整性约束
ALTER TABLE <表名> ADD <新列名称><数据类型>|[完整性约束]
限定范围:BETWEEN xxx AND xxx
SELECT *
FROM STUDENT
WHERE BirthDay BETWEEN ‘2000-01-01’ AND ‘2000-12-30’;
若要分专业统计STUDENT表中男生人数,但限定只显示人数大于2的人数,其查询SQL语句如下:
SELECT Major AS 专业, COUNT(StudentID) AS 学生人数
FROM Student
WHERE StudentGender=’男’
GROUP BY Major
HAVING COUNT(*)>2;
多表连接关联查询:SELECT <目标列>[,<目标列>…] FROM <表名1> JOIN <表名2> ON <连接条件>;
SELECT B.CollegeName AS 学院名称, A.TeacherID AS 编号, A.TeacherName AS 姓名, A.TeacherGender AS 性别, A. TeacherTitle AS 职称
FROM TEACHER AS A JOIN COLLEGE AS B
ON A.CollegeID=B.CollegeID
ORDER BY B.CollegeName, A.TeacherID;
权限授予:GRANT <权限列表> ON <数据库对象> TO <用户或角色> [ WITH GRANT OPTION ];