执行SHOW_SPACE存储过程时只能在DBA角色下成功,在NORMAL角色用户下报错:

ORA-10618: Operation not allowed on this segment
ORA-06512: at "SYS.DBMS_SPACE", line 167
ORA-06512: at "DMS.SHOW_SPACE", line 65
ORA-06512: at line 2

遇到ORA -error 第一件要做的事情就是查看 "error message"

ORA-10618: Operation not allowed on this segment
Cause: This DBMS_SPACE operation is not permitted on segments in tablespaces with
AUTO SEGMENT SPACE MANAGEMENT
Action: Recheck the segment name and type and re-issue the statement

意思就是说 dbms_space这个包只能在非自动段空间管理的表空间上用.

查查 dba_tablespaces.

Not quite correct. That particular operation, or procedure/function, is
only permitted on non-ASSM tablespace. But some other procedures, such
as spce_usage, is used on ASSM.

终于找到毛病了,原来是没有权限。虽然当前用户执行语句是有权限的,但是放到存储过程中就必须要显式的赋个权限给当前用户。以下是我找到的资料,贴出来给大家也看一下吧。
=====================
【IT168 技术文档】我们知道,用户拥有的role权限在存储过程是不可用的。如:  
 
  SQL> select from dba_role_privs where grantee='SUK';
 
  GRANTEE GRANTED_ROLE ADMIN_OPTION DEFAULT_ROLE
  ------------ ------------ ------------ ------------
  SUK DBA NO YES
  SUK CONNECT NO YES
  SUK RESOURCE NO YES
 
  --用户SUK拥有DBA这个role
 
  --再创建一个测试存储过程:
  create or replace procedure p_create_table  
  is
  begin
  Execute Immediate 'create table create_table(id int)';
  end p_create_table;
 
  --然后测试
  SQL> exec p_create_table;
 
  begin p_create_table; end;
 
  ORA-01031: 权限不足
  ORA-06512: 在"SUK.P_CREATE_TABLE", line 3
  ORA-06512: 在line 1
 
  --可以看到,即使拥有DBA role,也不能创建表。role在存储过程中不可用。
  --遇到这种情况,我们一般需要显式进行系统权限,如grant create table to suk;
  --但这种方法太麻烦,有时候可能需要进行非常多的授权才能执行存储过程
  --实际上,oracle给我们提供了在存储过程中使用role权限的方法:
  --修改存储过程,加入Authid Current_User时存储过程可以使用role权限。
  create or replace procedure p_create_table  
  Authid Current_User is
  begin
  Execute Immediate 'create table create_table(id int)';
  end p_create_table;
 
  --再尝试执行:
  SQL> exec p_create_table;
 
  PL/SQL procedure successfully completed
 
  --已经可以执行了。
权限是有的,只是执行的时候需要显式的声明一下。
 
第 1 行出现错误:
ORA-10618: Operation not allowed on this segment
ORA-06512: 在 "SYS.DBMS_SPACE", line 152
ORA-06512: 在 "SYS.SHOW_SPACE", line 21
ORA-06512: 在 line 1

发现这是由于表空间的ASSM方式引起的。
要能够执行该脚本,则需要在手动段空间管理模式下。
创建一个MSSM表空间:
SQL>
create tablespace mantbs datafile 'E:\oracle\oradata\lyon\mantbs01.dbf'
size 10m uniform. size 1m segment space management manual;
表空间已创建。

将用户在mantbs上的空间配额修改为不限制:
SQL> alter user lyon quota unlimited on mantbs;
用户已更改。

将表移动到该表空间下:
SQL> alter table bigcol move tablespace mantbs
  2  /
表已更改。

SQL> call show_space('BIGCOL',user);

调用完成。

SQL> show message;
SP2-0158: 未知的 SHOW 选项 "message"
SQL> set serveroutput on;
SQL> /
Free Blocks.............................0
Total Blocks............................128
Total Bytes.............................1048576
Unused Blocks...........................127
Unused Bytes............................1040384
Last Used Ext FileId....................23
Last Used Ext BlockId...................137
Last Used Block.........................1

调用完成。
即可查看该表占用空间情况。

 

ORA-10618: Operation not allowed on this segment 执行存储过程权限需声明的更多相关文章

  1. Operation not allowed after ResultSet closed--操作mysql数据库

    一个stmt多个rs进行操作.那么从stmt得到的rs1,必须马上操作此rs1后,才能去得到另外的rs2,再对rs2操作.不能互相交替使用,会引起rs已经关闭错误——Operation not all ...

  2. SQLExecption:Operation not allowed after ResultSet closed解决办法

    原网址:http://blog.csdn.net/sku0923/article/details/1722370 一个stmt多个rs进行操作引起的ResultSet已经关闭错误 一个stmt多个rs ...

  3. Operation not allowed for reason code "7" on table 原因码 "7"的解决

    对表进行任何操作都不被允许,提示SQLSTATE=57016 SQLCODE=-668 ,原因码 "7"的错误:SQL0668N Operation not allowed for ...

  4. 解决数据库Operation not allowed when innodb_forced_recovery > 0

    解决数据库Operation not allowed when innodb_forced_recovery > 0 请修改my.cnf innodb_force_recovery = 1 修改 ...

  5. Operation not allowed on a unidirectional dataset错误?

    关于网友提出的“ Operation not allowed on a unidirectional dataset错误?”问题疑问,本网通过在网上对“ Operation not allowed o ...

  6. dbexpress连接mysql提示Operation not allowed on a unidirectional dataset

    最近刚接触delphi,在了解到dbExpress连接mysql的时候,出现了一些问题,特记录下 我遇到的问题有两个 1. TDBGrid --DataSet=TDataSource1 TDataSo ...

  7. db2报错 Operation not allowed for reason

    1.DB2数据库表操作错误SQL0668N Operation not allowed for reason code "1" on table "XXXX". ...

  8. ORA-00392: log 4 of thread 2 is being cleared, operation not allowed

     alter database open resetlogs或者 alter database open resetlogs upgrade报错:ORA-00392 在rman restore 还原数 ...

  9. java.sql.SQLException: Operation not allowed after ResultSet closed

    转自:http://blog.csdn.net/hellobobantang/article/details/7173622 java.sql.SQLException: Operation not ...

随机推荐

  1. EF webapi json序列化 表间相互引用 无限循环问题解决方案

    WebApiConfig.cs中加入 如下代码即可解决无限循环问题 var json = config.Formatters.JsonFormatter; // 解决json序列化时的循环引用问题 j ...

  2. Delphi控件备份工具

    用途: 1.如果您需要重装Delphi,想省去重装控件的麻烦. 2.如果您把Delphi环境安装至另一台电脑上. 那么,您一定需要这个! 运行批处理后,自动在当前目录下生成备份目录. 批处理代码 @e ...

  3. utmp

    How to monitor user login history on CentOS with utmpdump Last updated on September 22, 2014 Authore ...

  4. python 用到的函数记录

    1. ctime() 获取当前的时间 2. import  random random.randint(0,99) 随机产生0到99之间的数值 (包含0和99) (整数!!) 3. 往列表添加数值 l ...

  5. Apache JMeter配置、安装

    一. 工具描述 apache jmeter是100%的java桌面应用程序,它被设计用来加载被测试软件功能特性.度量被测试软件的性能.设计jmeter的初衷是测试web应用,后来又扩充了其它的功能.j ...

  6. 解决“Can't bind to local 8630 for debugger”错误--查杀多余进程

    Can't bind to local 8630 for debugger 表明本地8630端口被占用 1.Windows平台 在windows命令行窗口下执行: 1.查看所有的端口占用情况 C:\& ...

  7. AWR实战分析之---- PX Deq Credit: send blkd (转载)

    该等待事件我在前面分析过,但是这次和上次产生的原因有些不一样,上次该等待事件的详细分析链接是:http://blog.sina.com.cn/s/blog_61cd89f60102eeen.html  ...

  8. 关于有些邮件可以在http上发送成功但是https不能发送成功一个思路方法

    关于有些邮件可以在http上发送成功但是https不能发送成功 其实如果是单纯的发送邮件,是没问题 今天一个客户出现这个问题,进行排查 他的邮件发送是任务制的, 是通过CURL请求的, 我估计她的CU ...

  9. zabbix_get无法执行agent端的脚本文件解决办法

    一,无法执行脚本参考网站:http://blog.51cto.com/13589448/2070180 权限不足时提示: server端提示: [root@yao local]# zabbix_get ...

  10. win10下装的ubuntu14.04双系统,ubuntu系统访问win10磁盘问题

    参考:https://blog.csdn.net/u010426270/article/details/52420231 ubuntu下 解决方法: 1. 在终端输入如下命令,查看分区挂载情况 sud ...