查看: 4331|回复: 5

ora-01031:insufficient privileges

[复制链接]
论坛徽章:
2
发表于 2006-5-25 12:18 | 显示全部楼层 |阅读模式
我在网上查询提示权限错误,但是自己还是找不出原因,


我单独运行问题,
SELECT distinct ta.table_name,tb.column_name,ta.constraint_type
  FROM dba_constraints ta,dba_cons_columns tb
where substr(ta.owner,1,8)= 'DBUSRPUB' and
                 ta.owner       = tb.owner and
       ta.constraint_name = tb.constraint_name and
       ta.table_name  = tb.table_name and
       ta.constraint_type(+) = 'P'


但是我创建视图的时候就出现问题咯
CREATE OR REPLACE VIEW REPTABCOLPK_VIEW AS
SELECT distinct ta.table_name,tb.column_name,ta.constraint_type
  FROM dba_constraints ta,dba_cons_columns tb
where substr(ta.owner,1,8)= 'DBUSRPUB' and
                 ta.owner       = tb.owner and
       ta.constraint_name = tb.constraint_name and
       ta.table_name  = tb.table_name and
       ta.constraint_type(+) = 'P'
招聘 : 数据库管理员
论坛徽章:
87
生肖徽章2007版:虎
日期:2009-03-02 15:42:532011新春纪念徽章
日期:2011-01-25 15:41:502011新春纪念徽章
日期:2011-01-25 15:42:152011新春纪念徽章
日期:2011-01-25 15:42:332011新春纪念徽章
日期:2011-01-25 15:42:562011新春纪念徽章
日期:2011-02-18 11:43:32数据库板块每日发贴之星
日期:2011-04-05 01:01:01现任管理团队成员
日期:2011-05-07 01:45:08鲜花蛋
日期:2011-06-26 11:15:422011新春纪念徽章
日期:2011-01-25 15:41:01
发表于 2006-5-25 12:20 | 显示全部楼层
没有创建视图的权限?

使用道具 举报

回复
论坛徽章:
2
 楼主| 发表于 2006-5-25 12:29 | 显示全部楼层
create or replace view test as
  select *
    from goods

创建其他视图都能正常创建

使用道具 举报

回复
论坛徽章:
52
ITPUB元老
日期:2006-02-14 08:33:40现任管理团队成员
日期:2011-05-07 01:45:08
发表于 2006-5-25 12:37 | 显示全部楼层

Re: ora-01031:insufficient privileges

最初由 msroom 发布
[B]我在网上查询提示权限错误,但是自己还是找不出原因,


我单独运行问题,
SELECT distinct ta.table_name,tb.column_name,ta.constraint_type
  FROM dba_constraints ta,dba_cons_columns tb
where substr(ta.owner,1,8)= 'DBUSRPUB' and
                 ta.owner       = tb.owner and
       ta.constraint_name = tb.constraint_name and
       ta.table_name  = tb.table_name and
       ta.constraint_type(+) = 'P'


但是我创建视图的时候就出现问题咯
CREATE OR REPLACE VIEW REPTABCOLPK_VIEW AS
SELECT distinct ta.table_name,tb.column_name,ta.constraint_type
  FROM dba_constraints ta,dba_cons_columns tb
where substr(ta.owner,1,8)= 'DBUSRPUB' and
                 ta.owner       = tb.owner and
       ta.constraint_name = tb.constraint_name and
       ta.table_name  = tb.table_name and
       ta.constraint_type(+) = 'P' [/B]


你的问题的原因是要对dba_constraints ,dba_cons_columns 这两个object进行直接授权,通过role方式的授权是不可以的,见如下的测试:

[php]
SQL> connect qiuyb/qiuyb@zhjs;
Connected to Oracle9i Enterprise Edition Release 9.2.0.5.0
Connected as qiuyb

SQL> SELECT distinct ta.table_name,tb.column_name,ta.constraint_type
  2  FROM dba_constraints ta,dba_cons_columns tb
  3  where substr(ta.owner,1,8)= 'DBUSRPUB' and
  4  ta.owner = tb.owner and
  5  ta.constraint_name = tb.constraint_name and
  6  ta.table_name = tb.table_name and
  7  ta.constraint_type(+) = 'P'
  8  /

TABLE_NAME COLUMN_NAME       CONSTRAINT_TYPE
---------- ----------------- ---------------

SQL>
SQL> CREATE OR REPLACE VIEW REPTABCOLPK_VIEW AS
  2  SELECT distinct ta.table_name,tb.column_name,ta.constraint_type
  3  FROM dba_constraints ta,dba_cons_columns tb
  4  where substr(ta.owner,1,8)= 'DBUSRPUB' and
  5  ta.owner = tb.owner and
  6  ta.constraint_name = tb.constraint_name and
  7  ta.table_name = tb.table_name and
  8  ta.constraint_type(+) = 'P'
  9  /

ORA-01031: insufficient privileges

--以dba_cons_columns单独建立一个视图也不可以
SQL> create or replace view view1 as select * from dba_cons_columns;

ORA-01031: insufficient privileges

SQL> connect / as sysdba
Connected to Oracle9i Enterprise Edition Release 9.2.0.5.0
Connected as SYS

SQL> grant select on
SQL> CREATE OR REPLACE VIEW REPTABCOLPK_VIEW AS
  2  SELECT distinct ta.table_name,tb.column_name,ta.constraint_type
  3  FROM dba_constraints ta,dba_cons_columns tb
  4  where substr(ta.owner,1,8)= 'DBUSRPUB' and
  5  ta.owner = tb.owner and
  6  ta.constraint_name = tb.constraint_name and
  7  ta.table_name = tb.table_name and
  8  ta.constraint_type(+) = 'P'
  9  .
10  
SQL>
SQL> grant select on dba_cons_columns to qiuyb;

Grant succeeded

SQL> grant select on dba_constraints to qiuyb;

Grant succeeded

SQL> connect qiuyb/qiuyb@zhjs
Connected to Oracle9i Enterprise Edition Release 9.2.0.5.0
Connected as qiuyb

SQL>
SQL> CREATE OR REPLACE VIEW REPTABCOLPK_VIEW AS
  2  SELECT distinct ta.table_name,tb.column_name,ta.constraint_type
  3  FROM dba_constraints ta,dba_cons_columns tb
  4  where substr(ta.owner,1,8)= 'DBUSRPUB' and
  5  ta.owner = tb.owner and
  6  ta.constraint_name = tb.constraint_name and
  7  ta.table_name = tb.table_name and
  8  ta.constraint_type(+) = 'P'
  9  /

View created

SQL>

sssss
[/php]

使用道具 举报

回复
论坛徽章:
2
 楼主| 发表于 2006-5-25 13:17 | 显示全部楼层
问题解决咯,感谢

使用道具 举报

回复
论坛徽章:
1
ITPUB十周年纪念徽章
日期:2011-11-01 16:21:15
发表于 2006-5-25 14:09 | 显示全部楼层
  怎么解决的

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表