开发者

Schema name vs. table name - how to avoid conflicts?

开发者 https://www.devze.com 2023-04-09 04:14 出处:网络
I\'ve to solve a problem using Oracle database. In Oracle database there are two schemas: XXX and YYY The schema XXX contains a table named YYY (the same name as the second schema).

I've to solve a problem using Oracle database.

In Oracle database there are two schemas: XXX and YYY

The schema XXX contains a table named YYY (the same name as the second schema).

The schema YYY contains some sequences (let's say sequence ZZZ) and log tables, which I need to use by triggers in schema XXX.

But when I try to write trigger over table XXX.some_table using this construction:

SELECT YYY.ZZZ.NEXTVAL INTO AAA FROM DUAL

Oracle considers YYY as table in XXX schema and show error message "component ZZZ must be declared". There are appropriate rights set for XXX user to access YYY.ZZZ sequence, but it is useless.

How to avoid this? Unfortunately the structure of 开发者_如何学运维database is set and can't be changed.


You can write trigger code, so you have some control over the database. That's good.

I suggest you use synonyms to work arround this:

create synonym yyy_zzz_seq for yyy.zzz;

You should then be able to reference the synonym in your trigger:

SELECT yyy_zzz_seq.NEXTVAL INTO AAA FROM DUAL
0

精彩评论

暂无评论...
验证码 换一张
取 消