logo 广告
Loading...
 导航 所在位置:论坛首页 -> ┈┋电脑网络┋┈ -> 数据库技术 -> 动态DDL执行与Schema Objects显示授权问题
回复
标题:动态DDL执行与Schema Objects显示授权问题收藏 编辑 删除 楼主 | 上一篇 下一篇
耸炮头
头像
等级:社区游侠
权限:普通用户
积分:37
金钱:1484
声望:52
经验:52
发帖数:381
注册:2007年12月10日
资料 短消息2008-7-25 16:14:08
这是一个大家常见的问题,也是很容易忽略的问题,尤其是在Procedure里面动态执行DDL语句的时候发生. 我们必须使用显示授权方式来保证DDL的执行权限, 而不能通过role的传递方式,下面是一个简单的测试过程来验证这一点.

参考说明:

If the referenced item is indeed declared and you believe that you have privileges to refer to that item, check the privileges; if the privileges were granted only via a role, then this is expected and documented behavior. Stored objects (packages, procedures, functions, triggers, views) run in the security domain of the object owner with no roles enabled except PUBLIC. Again, you will be notified only that the item was not declared

Test steps:

SQL> create user chris identified by pass;

User created.

SQL> grant dba to chris;

Grant succeeded.

SQL> connect chris/pass;

Connected.

SQL> create table test1 (name varchar2(10));

Table created.

--Success here.

SQL> drop table test1;

Table dropped.

SQL> create or replace procedure chris_cr_tbl

2 IS

3 begin

4 execute immediate 'create table test1 (name varchar2(10))';

5 end;

6 /

Procedure created.

SQL> exec chris_cr_tbl;

BEGIN chris_cr_tbl; END;

*

ERROR at line 1:

ORA-01031: insufficient privileges

ORA-06512: at "CHRIS.CHRIS_CR_TBL", line 4

ORA-06512: at line 1

--Failed Here

SQL> connect test/oracle

Connected.

SQL> grant create table to chris;

Grant succeeded.

--Explicit Grant

SQL> connect chris/pass

Connected.

SQL> exec chris_cr_tbl;

PL/SQL procedure successfully completed.

SQL> select table_name from all_tables where owner='CHRIS';

TABLE_NAME

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

TEST1

SQL> drop table test1;

Table dropped.

签名

2008-7-25 16:14:08 顶部
第1页 共页 共0个回复     <<    >>    
 快速回复
  • 支持UBB,HTML标签

  • 高级回复

  • 操作选项:评分 加精 解精 奖惩 设专题 设公告 解公告 固顶 总固顶 解固顶 结帖 解结帖 锁帖 解锁 移帖 删帖
      首页 | 购买指南 | 虚拟主机 | 特色介绍 | 下载中心 | 支付方式
    Copyright 2004-2008 BBSGood.com Powered By: BBSGood.Speed Version 5.0
      咨询电话:0575-85513832、0575-85513825(传真)、7*24小时咨询服务:13606552007 不良信息举报中心 浙ICP备05029817号
      业务QQ:38958768、客服QQ1:415896239、客服QQ2:343896043、MSN:jccsxx@hotmail.com