一、使用者
1、利用SQL建立使用者的文法格式如下:
create user user_name --使用者名稱*/ [identified by password | externally | globally as 'external_name'] --以何種方式驗證使用者,驗證方式有3種:口令、外部和全域, --口令表示利用建立使用者時提供的password進行驗證,外部表格示利用第三方程式來驗證,如作業系統的登入密碼,全域則指當有多個資料時, --建立一個全域的使用者,其他資料庫都以這個使用者來驗證,只有使用口令的時候才需要關鍵字by*/ [default tablespace tablespace_name] --指定使用者的預設資料表空間*/ [temporary tablespace tablespace_name] --指定使用者的暫存資料表空間*/ [quota integer K | integer M | unlimited on tablespace_name] --在指定資料表空間能分配的最大空間*/ [profile profile_name] --指定概要檔案*/ [default role roleName,..n | all[except roleName,...n] | none] --指定使用者擁有的角色,default是將一個或多個預設的 --角色分給使用者,all[except role]是把所有的角色或除某些角色以外的角色分給使用者,none表示不指定角色*/ [password expire] --表示使password失效,這將強制使用者在第一次登入資料庫時更換密碼*/ [account lock | unlock] --賬戶是否鎖定*/ 範例程式碼: create user hello identified by world password expire;
2、利用SQL修改使用者的文法格式如下:
alter user user_name identified by password | externally | globally as 'external_name'[default tablespace tablespace_name] [temporary tablespace tablespace_name] [quota integer K | integer M | unlimited on tablespace_name] [profile profile_name] [default role roleName | all[except roleName] | none] [password expire] [account lock | unlock] 例代碼: alter user hello identified by helloworld;
3、利用SQL命令刪除使用者的文法格式如下:
drop user user_name [cascade]; --使用cascade會把使用者擁有的對象一起刪除*/ 例代碼: drop user hello cascade;
二、角色
1、利用SQL語句建立角色的文法格式如下:
create role role_name [not identified] [identified by password | externally | globally]
範例程式碼
create role hello;
2、利用SQL語句修改角色的文法格式如下:
alter role role_name [not identified] [identified by password | externally | globally]
3、利用SQL語句刪除角色的文法格式如下
drop role role_name