oracle对象权限备份,Oracle 对象权限

--============================

--author:_yeeXun

--date:12/31/2010 11:05:00 AM

--address:Jau 17-304

--============================

对象权限指访问其他方案的权利,用户直接访问自己的方案的对象,但是如果要访问别的方案的对象,则必须具有对象的权限。

比如smith用户要访问scott.emp表(scott:方案,emp:表),则不需再scott.emp表上具有对象的权限。

常用的对象权限:

Alter   --修改(修改表结构)    delete  --删除

Select  --查询insert  --添加

Update  --修改(更新数据)      index   --索引

References  --引用execute  --执行

显示对象权限

通过数据字典视图可以显示用户或角色所具有的对象权限:dba_tab_privs;

授予对象权限

在oracle9i前,授予对象权限是由对象的所有者来完成的,如果用其他的用户来操作,则需要用户具有相应的(with grant option)权限,从oracle9i开始,dba用户(sys,system)可以将任何对象上的对象权限授予其他用户,授予对象权限是用grant命令来完成的。

对象权限可以授予用户,角色,和public。在授予权限时,如果带有with grantoption选项,则可以将该权限转授给其他用户,但是要注意with grant option选项不能被授予角色。

小案例

1.monkey用户要操作scott.emp表,则必须授予相应的对象权限

a)希望monkey可以查询scott.emp的表数据,怎样操作?

首先建立一个monkey用户

SQL> create user monkey identified by m123;

User created

给monkey用户授权

SQL> grant create session to monkey;

Grant succeeded

可以查看monkey用户具有连接数据库的权限

SQL> conn monkey/m123;

Connected to Oracle Database 10g Enterprise Edition Release10.2.0.1.0

Connected as monkey

用monkey用户查看scott方案的emp表,得到了失败的提示

SQL> select * from scott.emp;

select * from scott.emp

ORA-00942: 表或视图不存在

连接到scott用户,让scott用户为monkey用户授权

SQL> conn scott/tiger;

Connected to Oracle Database 10g Enterprise Edition Release10.2.0.1.0

Connected as scott

SQL> grant select on emp to monkey;

Grant succeeded

下面就是我们想要的结果:

SQL> select * from scott.emp;

EMPNO ENAME      JOB         MGR HIREDATE          SAL      COMMDEPTNO

----- ---------- --------- ----- ----------- --------- ---------------

8881 test用户   MANAGER    7782 2010-12-21      23.00     23.0010

......

15 rows selected

b)希望monkey可以修改scott.emp表的数据,怎样操作?

Sql> Grant update on emp to monkey;

c)希望monkey可以删除scott.emp表的数据,怎样操作?

Sql> Grant delete on emp to monkey;

d)  一次性将所有对scott.emp表的数据操作的权限授予monkey

Sql> Grant all on mep to monkey;

2.能否对monkey访问权限更加精细控制(授予列权限)

a)希望monkey只可以修改scott.emp表的sal字段,怎样操作?

Grant update on emp(sal) to monkey;

b)希望monkey只可以查询scott.emp表的ename,sal数据,怎样操作?

Grant select on emp(ename,sal) to monkey;

3.授予alter权限

如果monkey用户要修改scott.emp表的结构,则必须授予alter对象权限

Sql> conn scott/tiger;

Sql> grant alter on emp to monkey;

当然也可以由sys,system来完成此事。

4.授予execute权限

如果用户想要执行其他方案的包/过程/函数,则必须有execute权限。

比如为了让monkey用户可以执行dbms_transaction,可以授execute权限

Sql> conn system/manger;

Sql> grant execute on dbms_transaction to monkey;

5.授予index权限

如果想在别的方案的表上建立索引,则必须具有index对象权限,如:为了让monkey用户可以子scott.emp上建立索引,就给其index的对象权限

Sql> conn scott/tiger;

Sql> grant index on scott.emp to monkey with grant option

6.使用with grant option选项

该选项用于转授对象权限,但是该选项只能被授予用户,而不能授予角色

Sql> conn scott/tiger;

Sql> grant select on emp to monkey with grant option;

Sql> conn monkey/m123;

Sql> grant select on scott.emp to anybody;

回收对象权限

在oracle9i中,收回对象的权限可由对象的所有者来完成,也可以由dba用户(sys,system)来完成。

注意:收回对象权限后,用户就不能执行相应的sql命令,对象权限可以级联回收。

语法:revoke对象权限on对象from用户;

1.定义

2.对象权限有哪些

如何赋给对象权限

--the end--

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值