我创建了bm模式下的ctmat表为公共同义词,我在test模式下也可以查询,但我在建存储过程时总是说ctmat不存在:create or replace test(v_matno in ctmat.ctmatno%type )v_ctmatno varchar2(20);isbeginselect ctmatno into v_ctmatno from ctmat where ctmatno=v_matno;end;请问这要怎么才可以调用公共同义词ctmat也是同义词名
需要授权的
SQL> connect sys/system@racdb as sysdba已连接。
SQL> create user xys identified by manager default tablespace users;
用户已创建
SQL> grant dba to xys;
授权成功。
SQL> create user test identified by test default tablespace users;
用户已创建
SQL> grant dba to test;
授权成功。
SQL> create table xys.test(aa varchar2(10));
表已创建。
SQL> insert into xys.test values('test');
已创建 1 行。
SQL> commit;
提交完成。
SQL> create public synonym syn_test for XYS.TEST;
同义词已创建。
SQL> connect test/test@racdb已连接。
SQL> select * from syn_test;
AA
--------------------
test
SQL> connect sys/system@racdb as sysdba已连接。
SQL> grant select on syn_test to test;
授权成功。
SQL> connect test/test@racdb已连接。
SQL> create or replace procedure proc_test
2 is
3 v_test syn_test.aa%type ;
4 begin
5 select aa into v_test from syn_test ;
6 dbms_output.put_line(v_test);
7 end proc_test;
8 /
过程已创建。
SQL> set serveroutput on
SQL> execute proc_test;
test
PL/SQL 过程已成功完成。
SQL>
那不是我每一个公共 同义词都要这样授权吗?那不是很麻烦,有没有什么简便的方法
哥们啊,你可以写个
select 'grant select on '||SYNONYM_NAME || ' to user_name ' from dba_synonyms
还有个办法可以授权给public
Grant select on ctmat to public
或者直接在该用户下创建公共同义词
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/77580/viewspace-212827/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/77580/viewspace-212827/