oracle 對象管理 01_用戶及權限

1、用戶管理
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';   --查詢用戶緩存的SQLhtml

2、權限、角色管理
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'; //查詢用戶的表的列是否可處理session

相關文章
相關標籤/搜索