sql server 數據控制 權限

可視化工具創建刪除用戶:https://blog.csdn.net/hza419763578/article/details/82918915

所有用戶 to/from public                                                 所有權限:grant/revoke all privileges

 

 

1.grant授權

把查詢Student表的權限授給用戶U1     sql server表名前不需要加table

Grant select
on table student  --sql server不能加table
to u1;

 

 

把對錶student表和course表的全部操作權限授予用戶U2和U3

Grant all privileges
on student,course
to U2,U3;

 

 

把對錶SC的查詢權限授予所有用戶

Grant select
on SC
to public;

 

 

把查詢studnet表和修改學號的權限授予用戶U4

Grant select,update(sno)
on student
to U4;

 

 

把對錶SC的insert權限授予用戶U5,並允許將此權限再授予其他用戶

Grant insert
on SC
to U5
with grant option;

U5將insert權限給U6

Grant insert
on SC
to U6
with grant option;

也加了with grant option; 則U6也可以將此權限給U7

Grant insert
on SC
to U7;

U6給U7未加with grant option;則U7不能再傳播此權限

創建數據庫和創建表的權限給用戶xsuser1

grant create database 
to xsuser1;
grant create table 
to xsuser1;

 

 

 

2.revoke收回權限

由數據庫管理員或其他授權者用revoke語句收回授權

把用戶U4修改學號的權限收回

revoke update(sno)
on Student
from U4;

 

收回所有用戶對錶SC的查詢權限

revoke select
on SC
from public;

 

把用戶U5對錶SC的insert權限收回

revoke insert
on SC
from U5 cascade;

-- 因爲U5將權限傳播給了U6、U7、所以加上cascade,級聯收回U6,U7的insert權限,否則語句拒絕執行

 

 

3、創建數據庫模式的權限

create user <username> [with] [DBA|resource|connect];

新創建的數據庫用戶有三種級別的權限connect、resource和dba

create user 不指定權限 默認connect

權限對應的可執行操作
擁有權限 create user create schema create table 登錄,查詢和操縱
dba 可以 可以 可以 可以
resource 不可以 不可以 可以 可以
connect 不可以 不可以 不可以 可以,但要被賦予相應權限

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章