oracle ORA-02069 global_names 参数必须为此操作设置为 TRUE
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4688685/
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-02069 global_names parameter must be set to TRUE for this operation
提问by kupa
I've searched a couple of solutions. One of them is the following:
我已经搜索了几个解决方案。其中之一如下:
CauseA remote mapping of the statement is required but cannot be achieved because global_names should be set to TRUE for it to be achieved
原因需要语句的远程映射但无法实现,因为 global_names 应设置为 TRUE 才能实现
ActionIssue alter session set global_names = true if possible
行动,执行ALTER会议设置GLOBAL_NAMES = true,如果可能的
But I don't understand why should I need to set global_names parameter...Why does remote mapping use global_names parameter? Please,can you explain me?
但我不明白为什么我需要设置 global_names 参数......为什么远程映射使用 global_names 参数?拜托,你能解释一下吗?
P.S I know that setting global_names parameter will arise global naming rules,that the database link name must be the same as the remote database name..And also it appends domain name to the database name like <DB_NAME>.<DB_DOMAIN> what else?
PS我知道设置global_names参数会产生全局命名规则,数据库链接名称必须与远程数据库名称相同..而且它会在数据库名称后附加域名,例如<DB_NAME>.<DB_DOMAIN>还有什么?
回答by kupa
The answer is discussed here: http://dba010.wordpress.com/2011/01/05/oracle-errorsora/#ORA-02069
答案在这里讨论:http: //dba010.wordpress.com/2011/01/05/oracle-errorsora/#ORA-02069
In case link doesn't work:
如果链接不起作用:
Error:
错误:
ORA-02069: global_names parameter must be set to TRUE for this operation
ORA-02069: 此操作的 global_names 参数必须设置为 TRUE
Cause:
原因:
You are trying to make DML operation on the remote database using local function.
您正在尝试使用本地函数对远程数据库进行 DML 操作。
This is the “Oracle Bug”, it should work but it doesn't.
这是“Oracle 错误”,它应该可以工作,但没有。
Example (for better understanding):
示例(为了更好地理解):
–Assume that we have two databases DB1 and DB2
– 假设我们有两个数据库 DB1 和 DB2
–On DB1 we have function fun1
– 在 DB1 上我们有函数 fun1
create function fun1 return number is
begin
return 1;
end;
–On DB1 we have a database link referring to DB2 called, for simplicity, DB2.
– 在 DB1 上,我们有一个引用 DB2 的数据库链接,为简单起见,称为 DB2。
–Check that it works.
– 检查它是否有效。
select *
from dual@DB2
–If the output is the following, then it works.
– 如果输出如下所示,则它有效。
DUMMY
-----
X
–Let's create test table in DB2(connect to DB2 database)
– 让我们在 DB2 中创建测试表(连接到 DB2 数据库)
create table tesTable(
id number,
testColumn number
);
–Let's make some DML operation, which should cause this ORA-02069 error.
– 让我们做一些 DML 操作,这应该会导致这个 ORA-02069 错误。
insert into testable@DB2(id,testColumn)
values(1, fun1);
“ORA-02069: global_names parameter must be set to TRUE for this operation”
Now, when you already know in what situation this error occurs let's write the solution. It has two solutions:
现在,当您已经知道在什么情况下会发生此错误时,让我们编写解决方案。它有两种解决方案:
Solution one:
解决方案一:
- Set the global_names parameter to true, it can be done on the system level or session level(consider that session level sometimes is not available)
- 将 global_names 参数设置为 true,可以在系统级别或会话级别进行(考虑会话级别有时不可用)
--On DB1
--在DB1上
alter session set global_names=true;
- Create database link on the remote database, in our case on DB2, which will refer to the database DB1(make link name the same as the database global name, because setting global_names parameter to true requires it).
- 在远程数据库上创建数据库链接,在我们的例子中是在 DB2 上,它将引用数据库 DB1(使链接名称与数据库全局名称相同,因为将 global_names 参数设置为 true 需要它)。
–On DB2
– 在 DB2 上
Create database link DB1 connect to <username> identified by <password>
using ‘DB1';
Now it should work, but I should mention that creating database link may not be preferable,
现在它应该可以工作了,但我应该提到创建数据库链接可能不是可取的,
because it is not secure (You should guess why, because if you do this you will be able to connect to DB1 with some user through database link…if it doesn't matter for you then use itJ).
因为它不安全(您应该猜猜为什么,因为如果您这样做,您将能够通过数据库链接与某个用户连接到 DB1……如果对您来说无关紧要,则使用 itJ)。
Solution two:
解决方案二:
- Create temporary table on the local database.
- Insert row into the temporary table.
- Insert the temporary row from the temporary table to the remote database.
- Delete the temporary row. Note that this solution is slower than the first one. But it also solves the problem and is much more secure.
- 在本地数据库上创建临时表。
- 在临时表中插入行。
- 将临时表中的临时行插入到远程数据库中。
- 删除临时行。请注意,此解决方案比第一个解决方案慢。但它也解决了问题,而且更加安全。
回答by ccu
kupa's answer offers a great explanation and good solutions as well, however if you don't want to or are not able to follow solution one or two there, I suggest checking out solution 2 here: http://dbtricks.com/?p=263.
kupa 的回答也提供了很好的解释和很好的解决方案,但是如果您不想或无法遵循其中的一两个解决方案,我建议您在此处查看解决方案 2:http://dbtricks.com/?p =263。
This worked for me, creating a variable and assigning the value of the local function to it, then using the variable in the sql statement that referenced the remote table.
这对我有用,创建一个变量并将本地函数的值分配给它,然后在引用远程表的 sql 语句中使用该变量。
Hope this helps somebody as it helped me!
希望这对某人有所帮助,因为它帮助了我!
回答by Carlo Pires
Quoting this thread:
引用这个线程:
...in the past Oracle used .world as a default domain if domain
part was not specified in global db name, they changed it (I
believe in 10g R1, but I'm not sure)