Oracle创建及查看用户权限
本文将介绍的是通过创建一张表,进而实现Oracle创建用户权限的过程。以下这些代码主要也就是为实现Oracle创建用户权限而编写,希望能对大家有所帮助。
注意:每条语语分开执行,结尾必须用分号;
//创建空间
create tablespace test
datafile 'c:\oracle\oradata\orcl9\test.dbf' size 50M
default storage (initial 500K
Next 500K
minextents 1
maxextents unlimited
pctincrease 0);
//Oracle创建用户权限
//创建用户
create user lxg identified by lxg default tablespace test;
//授权
grant resource,connect,dba to test;
//删除表空间
drop tablespace "空间名" including contents and datafiles
删除用户 drop user "lxg" cascade
增加表空间 alter tablespace chinawater add datafile 'c:\oracle\oradata\orcl9\ADDCHINAWATER.dbf' size 200M
创建用户 create user userName identified by password; 创建用户 userName,密码为 password
给用户授权
grant dba to lxg;--授予DBA权限
grant unlimited tablespace to lxg;--授予不限制的表空间
grant select any table to lxg;--授予查询任何表
grant select any dictionary to lxg;--授予 查询 任何字典
===================================
授权语句--select * from dba_users; 查询数据库中的所有用户 --alter user TEST_SELECT account lock; 锁住用户 --alter user TEST_SELECT account unlock; 给用户解锁 --create user xujin identified by xujin; 建立用户 --grant create tablespace to xujin; 授权 --grant select on tabel1 to xujin; 授权查询 --grant update on table1 to xujin; --grant execute on procedure1 to xujin 授权存储过程 --grant update on table1 to xujin with grant option; 授权更新权限转移给xujin用户,许进用户可以继续授权; --收回权限 --revoke select on table1 from xujin1; 收回查询select表的权限; --revoke all on table1 from xujin; /grant connect to xujin; revoke connect from xujin grant select on xezf.cfg_alarm to xujin; revoke select on xezf.cfg_alarm from xujin;/ --select table_name,privilege from dba_tab_privs where grantee='xujin' 查询一个用户拥有的对象权限 --select * from dba_sys_privs where grantee='xujin' 查询一个用户拥有的系统权限 --select * from session_privs --当钱会话有效的系统权限 --角色 --create role xujin1;--建立xujin1角色 --grant insert on xezf.cfg_alarm to xujin1; 将插入表的信息 --revoke insert on xezf.cfg_alarm from xujin1; 收回xujin1角色的权限 --grant xujin1 to xujin ; 将角色的权限授权给xujin; -- create role xujin2; --grant xujin1 to xujin2; 将角色xujin1授权给xujin2; --alter user xujin default xujin1,xujin2; 修改用户默认角色 -- DROP ROLE xujin1;删除角色1; --select * from role_sys_privs where role=xujin1; --查看许进1角色下有什么系统权限; --select granted_role,admin_option from role_role_privs where role='xujin2'; --查看xujin1角色下面有什么角色权限 --select * from role_sys_privs where role='xujin2'; --select table_name,privilege from role_tab_privs where role='xujin1'; --select * from dba_role_privs where grantee='xujin' --查看用户下面有多少个角色;
*********** 查看数据库权限 ***********
1.查看所有用户: select * from dba_users; select * from all_users; select * from user_users;
2.查看用户或角色系统权限(直接赋值给用户或角色的系统权限): select * from dba_sys_privs; select * from user_sys_privs;
3.查看角色(只能查看登陆用户拥有的角色)所包含的权限
sql>select * from role_sys_privs;
4.查看用户对象权限: select * from dba_tab_privs; select * from all_tab_privs; select * from user_tab_privs;
5.查看所有角色: select * from dba_roles;
6.查看用户或角色所拥有的角色: select * from dba_role_privs; select * from user_role_privs;
7.查看哪些用户有sysdba或sysoper系统权限(查询时需要相应权限)
select * from V$PWFILE_USERS
注意:
1、以下语句可以查看Oracle提供的系统权限
select name from sys.system_privilege_map
2、查看一个用户的所有系统权限(包含角色的系统权限) select privilege from dba_sys_privs where grantee='DATAUSER' union select privilege from dba_sys_privs where grantee in (select granted_role from dba_role_privs where grantee='DATAUSER' );