oracle ORA-02070: 数据库在此上下文中不支持
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14153972/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ORA-02070: database does not support in this context
提问by Vivek
I have a query like
我有一个类似的查询
INSERT INTO sid_rem@dev_db
(sid)
select sid from v$session
Now, when i execute this query i get ORA-02070: database does not support in this context
现在,当我执行这个查询时,我得到 ORA-02070: database does not support in this context
This error happens only when I insert data from v$session into some remote db. Its working fine for any other table.
只有当我将数据从 v$session 插入某个远程数据库时才会发生此错误。它适用于任何其他表。
Anyone know why this issue and any workaround for this?
任何人都知道为什么会出现这个问题以及任何解决方法?
回答by Florin Ghita
Works using gv$session
instead of v$session
:
使用gv$session
代替v$session
:
INSERT INTO sid_rem@dev_db(sid)
select sid from gv$session;
gv$ views are global views, that is, they are not restricted to one node(instance), but see the entire database(RAC). v$ views are subviews of gv$.
gv$ 视图是全局视图,即它们不限于一个节点(实例),而是看到整个数据库(RAC)。v$ 视图是 gv$ 的子视图。
Searching on the internet I found this has something to do with distributed transactions.
在互联网上搜索我发现这与分布式事务有关。
回答by Ben
I don't know why this is happening, it's probably in the documentation somewhere but my Oracle-Docs-Fu seems to have deserted me today.
我不知道为什么会发生这种情况,它可能在某个地方的文档中,但我的 Oracle-Docs-Fu 今天似乎已经抛弃了我。
One possible work-around is to use a global temporary table
一种可能的解决方法是使用全局临时表
SQL> create table tmp_ben ( sid number );
Table created.
SQL> connect schema/pw@db2
Connected.
SQL> create table tmp_ben ( sid number );
Table created.
SQL> insert into tmp_ben@db1 select sid from v$session;
insert into tmp_ben@db1 select sid from v$session
*
ERROR at line 1:
ORA-02070: database does not support in this context
SQL> create global temporary table tmp_ben_test ( sid number );
Table created.
SQL> insert into tmp_ben_test select sid from v$session;
73 rows created.
SQL> insert into tmp_ben@db1 select * from tmp_ben_test;
73 rows created.
回答by Bob Jarvis - Reinstate Monica
Late answer but might still be useful. I've found this error occurs when trying to select from system views across a database link where the system view contains columns of type LONG. If the query can be reworded to avoid the LONG columns these joins will work fine.
迟到的答案,但可能仍然有用。我发现在系统视图包含 LONG 类型的列的数据库链接中尝试从系统视图中进行选择时,会发生此错误。如果查询可以改写以避免 LONG 列,这些连接将正常工作。
Example:
例子:
SELECT dc_prod.*
FROM dba_constraints@prod_link dc_prod
INNER JOIN dba_constraints dc_dev
ON (dc_dev.CONSTRAINT_NAME = dc_prod.CONSTRAINT_NAME)
will fail with an ORA-02070 due to accessing the LONG column SEARCH_CONDITION
, but
由于访问 LONG 列SEARCH_CONDITION
,将失败并显示 ORA-02070 ,但
SELECT dc_prod.*
FROM (SELECT OWNER,
CONSTRAINT_NAME,
CONSTRAINT_TYPE,
TABLE_NAME,
-- SEARCH_CONDITION,
R_OWNER,
R_CONSTRAINT_NAME,
DELETE_RULE,
STATUS,
DEFERRABLE,
DEFERRED,
VALIDATED,
GENERATED,
BAD,
RELY,
LAST_CHANGE,
INDEX_OWNER,
INDEX_NAME,
INVALID,
VIEW_RELATED
FROM dba_constraints@prod_link) dc_prod
INNER JOIN (SELECT OWNER,
CONSTRAINT_NAME,
CONSTRAINT_TYPE,
TABLE_NAME,
-- SEARCH_CONDITION,
R_OWNER,
R_CONSTRAINT_NAME,
DELETE_RULE,
STATUS,
DEFERRABLE,
DEFERRED,
VALIDATED,
GENERATED,
BAD,
RELY,
LAST_CHANGE,
INDEX_OWNER,
INDEX_NAME,
INVALID,
VIEW_RELATED
FROM dba_constraints) dc_dev
ON (dc_dev.CONSTRAINT_NAME = dc_prod.CONSTRAINT_NAME)
works fine because the LONG column SEARCH_CONDITION
from DBA_CONSTRAINTS is not accessed.
工作正常,因为SEARCH_CONDITION
未访问 DBA_CONSTRAINTS 中的 LONG 列。
Share and enjoy.
分享和享受。