作業11

授權
GRANT <權限>[,<權限>]…
ON <對象類型> <對象名>[,<對象類型> <對象名>]…
TO <用戶>[,<用戶>]…
[WITH GRANT OPTION];
4.1]把查詢Student表權限授給用戶U1
grant select
on student
to u1;
在這裏插入圖片描述
[4.2]把對Student表和Course表的全部權限授予用戶U2和U3
grant all privileges
on student
to u2,u3;
grant all privileges
on course
to u2,u3;
[4.3]把對錶SC的查詢權限授予所有用戶
grant select
on sc
to public;
[4.4]把查詢Student表和修改學生學號的權限授給用戶U4
grant select,update(sno)
on student
to u4;
[4.5]把對錶SC的INSERT權限授予U5用戶,並允許他再將此權限授予其他用戶。
grant insert
on sc
to u5
with grant option;
[4.6]U5授權給U6
grant insert
on sc
to u6
with grant option;
4.8]把用戶U4修改學生學號的權限收回
revoke update(sno)
on student
from u4;
[4.9]收回所有用戶對錶SC的查詢權限
revoke select
on sc
from public;
[4.10]把用戶U5對SC表的INSERT權限收回
revoke insert
on sc
from u5;
[4.11]通過角色來實現將一組權限授予一個用戶。
創建角色:
create role a1;
授權:
grant select,update,insert
on student
to a1;
把角色權限授予給用戶:
grant a1
to U1,U2,U3;
將用戶權限收回:
revoke a1
from U1,U2;
//標準SQL但在SQLSEVER中不可用,等價於:
exec sp_droprolemember ‘a1’,‘U1’
exec sp_droprolemember ‘a1’,‘U2’
[4.12]角色的權限修改。
grant delete
on student
to a1;
[4.13]使a1減少了SELECT權限
revoke select
on student
from a1;
強制存取控制規則
規則:
(1)僅當主體的許可證級別大於或等於客體的密級時,該主體才能讀相應的客體
(2)僅當主體的許可證級別小於或等於客體的密級時,該主體才能寫相應的客體
[4.14]建立計算機系學生的視圖,把對該視圖的SELECT權限授於王平,把該視圖上的所有操作權限授於張明

create view cs_s
as
select *
from student
where sdept=‘cs’;
//創建視圖
grant select
on cs_s
to 王平;
//在視圖的基礎上進行授權
grant all
on cs_s
to 張明;
審計
[4.15]對修改SC表結構或修改SC表數據的操作進行審計
audit alter,update
on sc;
[4.16]取消對SC表的一切審計
onaudit alter,update
on sc;
其中有錯誤的地方,還沒想搞明白是怎麼回事。。努力解決ing

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