什么是@!在From语句中表示

时间:2012-07-26 14:17:41

标签: sql oracle dblink

我正在尝试确定此代码正在做什么(Oracle SQL) - 尤其是from子句中的 at-sign感叹号

INSERT INTO "LOCATIONS" "A1"
            ("LOCATION_ID",
             "SEQUENCE",
             "POINT_TYPE")
SELECT "A2"."LOCATION_ID",
       "A2"."SEQUENCE",
       "A2"."LOCATION_TYPE",
       "A2"."POINT_TYPE"
FROM   "LOCATIONS"@! "A2"
WHERE  NOT EXISTS (SELECT 1
                   FROM   "LOCATIONS" "A3"
                   WHERE  "A3"."LOCATION_ID" = "A2"."LOCATION_ID") 

2 个答案:

答案 0 :(得分:5)

这是指向执行查询的原始数据库的反向数据库链接。原始查询必须如下所示:

INSERT INTO LOCATIONS@remote_db
            ("LOCATION_ID",
             "SEQUENCE",
             "POINT_TYPE")
SELECT "A2"."LOCATION_ID",
       "A2"."SEQUENCE",
       "A2"."POINT_TYPE"
FROM   "LOCATIONS" A2
WHERE  NOT EXISTS (SELECT 1
                   FROM   LOCATIONS@remote_db A3
                   WHERE  "A3"."LOCATION_ID" = "A2"."LOCATION_ID");

这样,所有远程表都变为本地,本地表变为远程“@!”。

答案 1 :(得分:-1)

我认为这不是有效的SQL。检查代码以确保在执行SQL之前没有任何更改 - 特别是检查数据库链接的名称是否替换为!

如果无法确定正在执行的内容,可以在数据库中设置跟踪