What does @ ! mean in a From Statement

ⅰ亾dé卋堺 提交于 2020-01-02 04:15:50

问题


I am trying to determine what this code is doing (Oracle SQL) — especially the at-sign exclamation mark in the from clause.

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") 

回答1:


This is a reverse database link to the original database, where the query is executed. The original query must look like:

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");

That way all remote tables become local, and local tables become remote with "@!".




回答2:


I don't think this is valid SQL. Check your code to make sure nothing is changed before the SQL is executed - particularly check to see if the name of a database link is being substitued for the ! .

If you can't determine what is being executed, you could put a trace on the database



来源:https://stackoverflow.com/questions/11671303/what-does-mean-in-a-from-statement

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!