[英]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. 嗨,我在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.
如果一个数据库名为Issue,另一个数据库称为Hub。 The table I want the results to go in is in the DB Hub.
我希望结果放入的表在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;
从db2.table2插入db1.table1(col1)SELECT col2;
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: 以用户ISSUE身份登录并执行以下语句:
GRANT SELECT ON TABLE1 TO HUB;
GRANT SELECT ON TABLE2 TO HUB;
login again as HUB and try again your select statement. 以HUB身份再次登录,然后重试您的select语句。
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. 如果您的数据库用户位于不同的Oracle实例上,则需要从HUB到ISSUE的数据库链接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.