我建了一个用户tmp并已授权。
grant dba, resource, connect, select any table to tmp;
然后,我在sql * plus 窗口中查询:
select t.VALUE from v$parameter t where t.NAME = ''db_block_size';
上面的sql语句是可以查到数据的,
但是我在存储过程里运行同样的sql语句却不行
begin
v_sqlstr := 'select t.VALUE from v$parameter t where t.NAME
= ''db_block_size''';
execute immediate v_sqlstr into v_DB_BLOCK_SIZE;
end;
报ora-00942错误:表或视图不存在。
表v$parameter是系统表确实存在,而且已经授权给tmp用户了,为什么单独在sql*plus窗口中执行,而在存储过程中执行就不行。
v$parameter is a synonym for sys.v_$parameter .
in this case, those two listed below are the same
grant select on v_$parameter to tmp;
or
grant select on v$parameter to tmp;
虽然v$parameter是v_$parameter的同义词,
但使用sys授权,只能用v_$parameter,而不能用v$parameter
----------------------------------------------------------------------------------------------------
SQL> grant select on v$parameter to tmp;
grant select on v$parameter to tmp
*
第 1 行出现错误:
ORA-02030: 只能从固定的表/视图查询
SQL> grant select on v_$parameter to tmp;
授权成功。