Oracle 角色授權與安全



oracle與操作系統集成,在xp中建立ora_dba組,並將安裝用戶加入該組,使之成爲DBA,因此在sqlplus中,普通用戶tom

,可以用:
connect tom/tomcat as sysdba;
登錄,也可以如下登錄:
connect / as sysdba;

創建用戶:
oracle不支持先輸數字,再跟字母的口令。
概要文件:配置文件。
表空間:一定要指定。

授予權限:
grant SELECT ON dept TO tester;
revoke SELECT ON dept FROM tester;
grant SQL命令 ON 表 TO 用戶;
revoke SQL命令 ON 表 FROM 用戶;

create user tom identified by tomcat;
grant connect to tom;
grant resource to tom;

授權成功。


tom 用戶表:
grant all on t_staff to scott;
grant all on t_corp to scott;
grant all on t_abc to scott;

show user;
grant connect/resouce/dba to user;
revoke emp on select from user;

alter session set nls_date_format='yyyy_mm_dd';

create user tester profile default identified by test account unlock;
--賦給角色
grant connect to tester;
--賦給權限
grant select on scott.dept to tester;
--將users作爲test的默認表空間。
alter user tester default tablespace users;
--修改密碼
alter user tester identified by tester;
--鎖定用戶
alter user tester account lock;
--解除鎖定
alter user tester account unlock;
--再建用戶,默認使用users表空間
create user jones identified by jones default tablespace jones;
--刪除用戶
drop user jones cascade;
--授權tester對錶scott.dept有select權,且tester可對其它用戶授予該權限
grant select on scott.dept to tester with grant option;

--對存儲過程授權
grant execute on scott.myproc to tester;
--對創建用戶權限授權
grant create user to tester with grant option;
grant drop user to tester;

--如下級聯授權操作
conn / as sysdba;
--管理員將權限授予tester,可查詢scott.dept,並且tester可再授權
grant select on scott.dept to tester with grant option;
conn tester/test;
select * from scott.dept;
--tester將查詢scott.dept權限授予tom
grant select on scott.dept to tom with grant option;
--or
grant select on scott.dept to tom;
conn tom/tomcat;
select * from scott.dept;
--反向操作
conn / as sysdba;
--管理員收回tester的權限
revoke select on scott.dept from tester;
conn tester/test;
select * from scott.dept;
conn tom/tomcat;
select * from scott.dept;
--事實表明,如果管理員收回tester的權限,則tester授予tom的相同權限也被回收。

系統授權,可以加with admin option
對象授權,可以加with grant option
grant create user to tester with admin option;

角色授權:
create role myrole;
grant all on scott.dept to myrole;
grant all on scott.emp to myrole;
grant all on scott.staff to myrole;
grant all on scott.corp to myrole;

grant myrole to tester;
conn tester/test;
select * from scott.dept;

刪除角色權限,則對應用戶就沒有了該權限。
revoke all on scott.dept from myrole;

概要文件:創建、使用(網頁方式)。

發佈了44 篇原創文章 · 獲贊 5 · 訪問量 21萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章