2、ALTER TABLE table_name
ALTER COLUMN column_name
ADD drop //添加列或是约束
{ < column_definition > | < table_constraint >
alter table studentdrop constraint PK_student
3、UPDATE 表名称 SET 列名称 = 新值 WHERE 列名称 = 某值
CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name
ON { table | view } ( column [ ASC | DESC ] [ ,...n ] )
[ WITH < index_option > [ ,...n] ]
[ ON filegroup ]
7、like '' [escape '']
%:多个字符
—:一个字符
8、is not null /is null
9、where 中不能使用聚集函数
groupby中GROUP BY 子句分组依据列表的表达式中,不能使用聚合或子查询或别名。只能是表中的列
having
NULL &null
null 是一个字符串值
NULL 是空
10、子查询的查询条件不依赖于父查询的 不相关子查询
否则为相关子查询
In | exists
查询没有选003课程的学生信息 不存在选了003课程的情况
select * from S
where not exists
(select * from SC where S.id=sc.id and sc.cId='003')
11、union intersect except 并、交、差
select * from s,sc where sc.id=s.id and sc.cId='001' union select * from s,sc where sc.id=s.id and sc.cId='002'
12、视图:由一个或多个基表导出的表,是建立在基表之上的虚表,数据库只存放视图的定义,没有视图对应的数据,这些数据任存放在基表中
作用:
1、视图能简化用户的操作
2、视图为用户提供多种角度看待同一数据
3、视图在一定程度上提供了逻辑独立性
13、角色与权限
create role r1;
grant select,update
on s
to r1
grant r1
to lj
revoke select
on s
from r1
14、审计
audit noaudit
15、trigger 触发器
16、游标
17、procedure
联系客服