我有以下情况。我需要编写一个过程来给一个模式访问另一个的对象。事情是这个程序正由管理帐户通过flyway执行。
我尝试了很多选项,但面对以下几点:
Error starting at line : 3 in command - (my begin...end procedure)
Error report -
ORA-00942: table or view does not exist
ORA-06512: at line 3
00942. 00000 - "table or view does not exist"
我的代码:
ALTER SESSION SET CURRENT_SCHEMA = AppUser;
BEGIN
FOR R IN (SELECT owner, table_name FROM dba_tables WHERE owner='AppUser') LOOP
EXECUTE IMMEDIATE 'GRANT SELECT ON '||R.owner||'.'||R.table_name||' TO QAUser';
END LOOP;
END;
它都不能改变架构。
答案 0 :(得分:1)
您的所有者AppUser
为大小写混合。因此,在语句中使用它时需要引用它,否则Oracle会将其转换为大写。
所以你可以试试这个:
ALTER SESSION SET CURRENT_SCHEMA = AppUser;
BEGIN
FOR R IN (SELECT owner, table_name FROM dba_tables WHERE owner='AppUser') LOOP
EXECUTE IMMEDIATE 'GRANT SELECT ON "'||R.owner||'"."'||R.table_name||'" TO "QAUser"';
END LOOP;
END;
请参阅Oracle: What exactly do quotation marks around the table name do?