简体   繁体   中英

How to pass list of IDs from one Oracle schema to another?

I use the Oracle SQL developer to query the Oracle database

So, my simplified script is as follows:

alter session set current_schema=schema1;
select id from table1

alter session set current_schema=schema2;
select * from table2 where remote_id in (<the list from the 1st query in schema1>)

Currently I copy the list from one schema to another manually. How to automate passing the list?

Fully qualified database object references in Oracle are SCHEMANAME.OBJECTNAME so regardless of which schema is your current schema, you can reference objects in other schemas like so:

Select *
  from schema2.table2
 where remote_id in (select id from schema1.table1);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM