Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Query from random number of schemas.

kdwolfSep 15 2008 — edited Sep 15 2008
Dear All,

I need to run a query for a given my_table at once from a number of schemas :

SELECT *
FROM my_schema1.my_table
UNION ALL
SELECT *
FROM my_schema2.my_table

And I need it to be a dynamic one, as I see another client asking for the same.
Is there any better idea than using of a
FOR ... LOOP (SELECT du.username FROM dba_users du WHERE du.username LIKE 'my_schema%')
and then EXECUTE IMMEDIATE per each record in this LOOP?

Many thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 13 2008
Added on Sep 15 2008
1 comment
180 views