简体   繁体   中英

Querying a database and insert resulting into a table in a seperate database in Oracle SQL Developer

Hi I have two database connections in Oracle SQL developer. I am trying to query results out of one database and insert them into another. If one database is named Issue and the other one named Hub. The table I want the results to go in is in the DB Hub. So in a worksheet in the hub database would I do something like this?

INSERT INTO RESULTS
SELECT ...
FROM ISSUE.TABLE1 ISSUE1,
ISSUE.TABLE2 ISSUE2,
WHERE ...

However when I do this I get this error:

 SQL Error: ORA-00942: table or view does not exist
 00942. 00000 -  "table or view does not exist"

I am connecting to the database Issue incorrectly?

Thanks,

This came directly out of the manual; INSERT INTO db1.table1(col1) SELECT col2 FROM db2.table2;

Did you try reading the manual about cross database inserts?

Most probably you have problems with your privileges.

Try this:

login as user ISSUE and execute this statement:

GRANT SELECT ON TABLE1 TO HUB;
GRANT SELECT ON TABLE2 TO HUB;

login again as HUB and try again your select statement.

I'm not at my desk, therefore I can't test it on my own.

If your database users are on different Oracle instances, then you need a database link from HUB to ISSUE.

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