1. 程式人生 > >oracle 模式,使用者,角色

oracle 模式,使用者,角色

oracle 中的模式和使用者:
[quote] 建立一個使用者,就相應的建立了 一個模式。[/quote]
[quote]CREATE SCHEMA有時只是為了滿足SQL標準[/quote]

要想在新建一個schema 則只有新建一個使用者。


使用者和角色 :
[quote]
角色就是一些許可權的集合:
為了方便管理,我們把某些常用的許可權組織成一個集合。賦予角色。然後把角色賦予使用者。提高管理的效率。例如建立一個數據庫某個模式,某幾個使用者下的的只讀使用者,可讀可插入使用者,等等。在實質生產中還是有很大的意義。

1.建立角色,不指定密碼:
create role testrole;

2.建立角色,指定密碼:
create role testrole identified by tanfufa;
3.修改角色:
alter role testrole identified by luqiaoling;
給角色授予許可權。
Grant select on t1 to testrole;
Grant select on t2 to testrole;
Grant select on t3 to testrole;

把角色賦予使用者:(特別說明,授予角色不是實時的。如下:)
grant testrole to testdb;

起用角色:給使用者賦予角色,角色並不會立即起作用。
1.角色不能立即起作用。必須下次斷開此次連線,下次連線才能起作用。
2.或者執行命令:有密碼的角色set role testrole identified by tanfufa 立即生效;
3.無密碼的角色:set role testrole;或set role all except rolename_withpassword.

把角色賦予角色,角色巢狀。
create role testrole1;
grant select on t1 to testrole1;
create role testrole2;
grant testrole1 to testrole2;
grant r2 to testdb;

角色管理:
與角色有關係的檢視:
所有角色:
select * from dba_roles;

當前使用者scott有哪些角色:
select * from session_roles; [/quote]