您的位置:首页 > 数据库 > Oracle

Oracle中的一些常见的用户操作

2013-05-09 00:00 197 查看
查看oracle所有用户:

select * from dba_users;

建立用户

create user 用户名 identified by 密码;

删除用户以及用户所有的对象

drop user 用户名 cascade;
//cascade参数是级联删除该用户所有对象,经常遇到如用户有对象而未加此参数则用户删不了的问题,所以习惯性的加此参数

锁住用户
alter user 用户名 account lock;

给用户解锁
alter user 用户名 account unlock;

授权创建表空间
grant create tablespace to 用户名;

授权查询
grant select on table1 to 用户名;

授权更新
grant update on table1 to 用户名;

授权存储过程
grant execute on procedure1 to 用户名;

授权更新权限给用户,并允许用户可以继续授权
grant update on table1 to 用户名 with grant option;

授予DBA权限
grant dba to 用户名;

所有权限
grant all on 数据库名称 to 用户名;

授予不限制的表空间
grant unlimited tablespace to 用户名;

授予查询任何表
grant select any table to 用户名;

授予查询任何字典
grant select any dictionary to 用户名;

收回查询table1表的权限
revoke select on table1 from 用户名;

收回对table1表操作的所有权限
revoke all on table1 from 用户名;

查询一个用户拥有的对象权限
select table_name,privilege from dba_tab_privs where grantee='user_name';

查询一个用户拥有的系统权限
select * from dba_sys_privs where grantee='user_name';

当前会话有效的系统权限
select * from session_privs;

建立角色zhu1
create role zhu1;

将插入表的信息权限授予角色zhu1
grant insert on xezf.table1 to zhu1;

收回角色zhu1的权限
revoke insert on xezf.table1 from zhu1;

将角色zhu1授权给zhu
grant zhu1 to zhu;

修改用户默认角色
alter user 用户名 default zhu1,zhu2;

删除角色zhu1
drop role zhu1;

查看角色zhu1下面有什么系统权限
select * from role_sys_privs where role=zhu1;

查看用户下面有多少的角色
select * from dba_role_privs where grantee='zsq';
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Oracle 用户操作