1、用戶
create user user_name identified by pwd ;--創建用戶
alter user user_name identified by newpwd;--修改用戶密碼
上面創建好的用戶還不能登錄數據庫,必須給一個create session系統權限
2、特權
常用系統特權:
create session—會話、create sequence—序列、create synonym—同義詞、create table—表(當前用戶下)、create any table—所有用戶下、drop table、drop any table、create procedure—存儲過程、create any procedure、create user、drop user、create view
grant create table,create any table,... to user_name [with admin option];-- 賦權語句 [with admin option]表示user_name這個用戶可以把前面獲得的create table,crate any table,...權限賦給其他用戶;
revoke create table,create any table,... from user_name;-- 收回權限
select * from user_sys_privs;-- 查看權限
常用對象特權:
select、update、insert、delete、execute
grant select,update,...on scott.dept to user_name;--賦權給user_name用戶scott用戶下的dept表的select,update等權限
revoke update on scott.dept from user_name;--收回權限
select * from user_tab_privs_recd;--查詢權限
select * from user_tab_privs_made;--查詢對其他用戶開放的表的權限
3、角色
create role emp_manager;-- 創建角色
grant select,update,delete,insert on scott.emp to emp_manager;-- 給角色賦權
grant emp_manager to user_name;--給user_name授予emp_manager角色
select * from role_tab_privs;-- 查詢角色的權限
revoke all on scott.emp from emp_manager;--取消所有的權限
drop role emp_manager;-- 刪除角色
4、審計
grant audit any to user_name;--授予審計的權限
audit create table;--審計創建表
select username,extended_timestamp,audit_option from user_audit_trail where audit_option = ‘CREATE TABLE’;--讀取創建表的記錄