oracle 对象管理 01_用户及权限

一、用户管理
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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值