打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
SQl
数据定义 create drop alter
数据查询 select
数据修改 delete update insert
数据控制 grant revoke

1、 foreign key (dId) references D(dId )//括号的添加

constraint //注意拼写  PK primary key (id)

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 列名称 = 某值
update s
set name=''  where id=''

4、drop table s cascase|restrict
5、delete from table
6、聚集索引的好处就是可以让数据按照此索引的顺序进行物理位置存放

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




本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
SqlServer 分区视图实现水平分表
SQL基础(二)
数据库SQL---数据库、基本表、视图、索引的定义、修改、删除
SQL Server 中使用Check 约束提升性能
第03章 SQL的数据定义和完整性约束
关系模型的三类完整性约束
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服