SQL-续
not null 与 unique
not null
略
unique
1 | unique (A_1, A_2, ... , A_n) |
后接属性集,可作为候选码。
check
类似where,后面接条件。
1 | create table s_table ( |
外码约束
1 | foreign key S references table_name |
级联
1 | # 主表ddl |
check
1 | # 嵌套子查询表达某个属性取值的范围 |
作用
当某个属性只是参照完整性约束下的码而不是外码,可以用check clause对这种情况进行描述。
在创建表的时候描述为对某种参照情况的描述。
index
1 | create table main_table ( |
作用
可以快速检索,详见11章
create type
1 | # 包装类型 |
大数存储
- blob 数字型大数
- clob 字符型大数
授权
Authorization
- 数据授权
- Read: allow reading.
- Insert: allow insert, not modification.
- Update: allow modification.
- Delete: allow deletion.
- 结构授权
- Index: allow create and deletion of Indices.
- Resourse: allow creation of relation.
- Alteration: allow addition or deletion of attribute in a relation.
- Drop: allow deletion of relations.
grant
1 | grant <priviege list> on <relation name or view name> to <user list>; |
<priviege list>:
- insert
- update
- delete
- select
- all privieges
<user list>:
- a user-id
- public, allow all user valid users the priviledge granted
- a role
revoke
回收权限
1 | revoke <priviledge list>; |
all 代表全体用户。
public 代表非指明的用户。
特殊情况
当某个用户在同一个权限上被授予两次,每次调用revoke会回收其中一条权限。
role
1 | craete role instructor; |
作用
当某个用户从表中删除,其关联的角色所授予的权限仍然有效。