`
chaoyi
  • 浏览: 289931 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

Oracle 权限管理

 
阅读更多

对象权限

/*
===========================================================
|          对象权限
============================================================
*/


--授予用户A_hr修改System模式下employee表(ename, sal)的权限
GRANT UPDATE(ename, sal) ON employee 
   TO A_hr;

GRANT ALL ON employee 
   TO A_hr 
   WITH GRANT OPTION;

--撤销权限
REVOKE ALL ON employee FROM A_hr;

--
UPDATE system.employee SET sal=sal+100 WHERE empno=7788;
select * FROM system.employee;
ROLLBACK;

 

撤消对象权限演示

Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。

C:\Users\aixin.shi>sqlplus system/orcl@orcldb

SQL*Plus: Release 11.2.0.1.0 Production on 星期一 10月 14 17:02:34 2013

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options


SQL> grant select on scott.emp to user1 with grant option;

授权成功。

SQL> conn user1/user1@orcldb
已连接。
SQL> grant select on scott.emp to user2 with grant option;

授权成功。

SQL> conn user2/user2@orcldb
已连接。
SQL> select count(*) from scott.emp;

  COUNT(*)
----------
        14

SQL> conn system/orcl@orcldb
已连接。
SQL> revoke select on scott.emp from user1;

撤销成功。

SQL> conn user2/user2@orcldb
已连接。
SQL> select count(*) from scott.emp;
select count(*) from scott.emp
                           *
第 1 行出现错误:
ORA-00942: 表或视图不存在

 

系统权限

/*
===========================================================
|          系统权限
============================================================
*/
--授予连接会话权限
GRANT CREATE SESSION TO A_hr;

--授予创建表权限
GRANT CREATE TABLE TO A_hr;

--权限合并
GRANT CREATE SESSION,CREATE TABLE TO A_hr;

--多个用户
GRANT CREATE SESSION,CREATE TABLE TO A_hr,A_oe;

--将权限授予所有用户
GRANT CREATE SESSION,CREATE TABLE TO PUBLIC;

--使被授予者进一步将权限或角色授予其他用户或角色
GRANT CREATE TABLE TO A_hr WITH ADMIN OPTION;

--撤销权限
REVOKE CREATE TABLE FROM A_hr;

--查询权限
SELECT * FROM DBA_SYS_PRIVS WHERE grantee ='A_HR';

 

撤消系统权限演示

Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。

C:\Users\aixin.shi>sqlplus system/orcl@orcldb

SQL*Plus: Release 11.2.0.1.0 Production on 星期一 10月 14 17:08:39 2013

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing optio


SQL> create user user1 identified by user1;

用户已创建。

SQL> create user user2 identified by user2;

用户已创建。

SQL> create user user3 identified by user3;

用户已创建。


SQL> grant create session,create table to user1 with admin option;

授权成功。

SQL> conn user1/user1@orcldb
已连接。
SQL> create table t(t1 number);

表已创建。

SQL> grant create session,create table to user2 with admin option;

授权成功。

SQL> conn user2/user2@orcldb
已连接。
SQL> create table t(t2 number);

表已创建。

SQL> conn system/orcl@orcldb
已连接。
SQL> revoke create table from user1;

撤销成功。

SQL> conn user1/user1@orcldb
已连接。
SQL> create table t2(t1 number);
create table t2(t1 number)
*
第 1 行出现错误:
ORA-01031: 权限不足


SQL> conn user2/user2@orcldb
已连接。
SQL> create table t2(t1 number);

表已创建。

SQL> grant create session,create table to a_hr with admin option;

授权成功。

SQL>

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics