oracle 对象管理 01_用户及权限
2019獨角獸企業重金招聘Python工程師標準>>>
一、用戶管理
1.創建用戶(可帶用戶的profile文件,對用戶的約束信息)
? ? CREATE USER username IDENTIFIED BY password DEFAULT TABLESPACE tablespace1 TEMPORARY TABLESPACE tablespace2;
2.修改用戶(密碼,表空間,加鎖解鎖)
? ? ALTER USER username IDENTIFIED BY password DEFAULT TABLESPACE tablespace1 TEMPORARY TABLESPACE tablespace2;
? ? Alter user acc01 account lock[unlock];
? ? Alter user acc01 account unlock;
?? ?ORA-01045:創建完用戶要給connect,resource權限否則沒法正常連接
3.刪除用戶及其對象
? ? DROP USER us1 CASCADE;
4.用戶相關信息查詢
? ? select * from dba_users; ? ?--所有用戶全量信息
? ? select * from all_users; ? ?--用戶簡要
? ? select * from user_users; ? --當前用戶自身信息
?? ?select * from v$session where username='HR'; ? ? ? ? ? --查詢用戶會話
?? ?select * from v$open_cursor where user_name='SCOTT'; ? --查詢用戶緩存的SQL
二、權限、角色管理
1.權限,角色
權限
? ? 系統權限:用戶操作數據庫系統對象的權限(系統權限是對用戶而言)。
? ? 對象權限:用戶對其它用戶對象的操作權限(是針對表或視圖等數據庫對象)。
角色
? ? 角色是一組權限的集合,將角色賦給一個用戶,這個用戶就擁有了這個角色中的所有權限。
常見角色:
? ? 創建實體對象:RESOURCE
?? ?創建會話,登陸oracle:CONNECT
?? ?擁有DBA權限:DBA
?? ?訪問數據字典視圖和包:DELETE_CATALOG_ROLE, EXECUTE_CATALOG_ROLE, SELECT_CATALOG_ROLE
?? ?數據導入導出工具:EXP_FULL_DATABASE, IMP_FULL_DATABASE
角色管理:
? ? create role role1;
? ? grant create any table,create procedure to role1;
? ? grant role1 to user1;
? ? drop role role1;?
2.授予回收角色或權限
? ? 系統權限和角色(包括普通用戶創建的角色)只能用 with admin option 級聯傳遞且不會級聯回收,普通用戶權限
只能用 with grant option 級聯傳遞同時級聯回收。
? ? 授權
? ? ? ? grant connect, resource, dba to 用戶名1 [,用戶名2]... with admin option; ? --可同時授予多用戶
? ? ? ? grant select, update on product to user02 ?with grant option;
? ? ? ? grant all on product to public; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?--授予所有人
? ? ? ? grant insert[,delete,|update,|select] on scott.emp to jack; ? ? ? ? ? ? ? ?--級聯授予
? ? 回收撤銷,系統權限只能由DBA用戶回收
? ? ? ? Revoke connect, resource from user50;
? ? ? ? Revoke select, update on product from user02;
? ? ? ? revoke insert[,delete,|update,|select] on scott.emp from jack;
3.權限,角色相關視圖
?? ?select * from all_tab_privs where grantee in ('PUBLIC','HR'); ? ? ? ? ?--用戶獲得表對象相關權限
?? ?select * from all_tab_privs where grantor='SCOTT'; ? ? ? ? ? ? ? ? ? ? --用戶授出表對象相關權限
?? ?select * from user_tab_privs where grantee ='HR' ? ? ? ? ? ? ? ? ? ? ? --用戶已獲得的權限
?? ?select * from dba_role_privs where grantee ='HR'; ? ? ? ? ? ? ? ? ? ? ?--用戶獲得系統角色
? ? select * from dba_sys_privs where grantee ='HR'; ? ? ? ? ? ? ? ? ? ? ? --用戶獲得系統權限
? ? select * from role_sys_privs where role in ('CONNECT','RESOURCE'); ? ? --系統角色對應的權限
參考資料:
http://www.cnblogs.com/fengqingtao/archive/2010/06/23/1763856.html?? ?
file:///F:/oracle/官方文檔/10G/10G/server.102/b14231/secure.htm#i1007931
? ? select owner, table_name from all_tables; // 用戶可以查詢的表
? ? select table_name from user_tables; ?// 用戶創建的表
?? ?SELECT * FROM USER_UPDATABLE_COLUMNS WHERE TABLE_NAME = 'VW_DEPT_EMP'; //查詢用戶的表的列是否可處理
轉載于:https://my.oschina.net/peakfang/blog/2245323
總結
以上是生活随笔為你收集整理的oracle 对象管理 01_用户及权限的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: sprintboot-learn(一)
- 下一篇: 了解一下ES6: 函数简述深浅拷贝