Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclamation mark in SQL (Oracle)

Tags:

sql

oracle

Looking at V$SQL in my database, I have just found a strange query that looks like :

UPDATE "MYTABLE" "A1" SET "SOMECOLUMN" = (
    SELECT "A2"."ANOTHERCOLUMN" 
    FROM "ANOTHERTABLE"@! "A2" 
    WHERE "A2".ROWID=:B1
)

Does anyone know the meaning of the syntax @!

I have never seen something like it before in Oracle

Thanks

like image 752
jeleb Avatar asked Feb 04 '14 09:02

jeleb


1 Answers

It's a query that has originated on a remote database. The database where you've seen this query in V$SQL has been referenced in the query on the remote database using the @DB_NAME syntax

The remote database has pushed the query to your database for execution, but to answer the query, your database needs to pull some information back from the remote database. This is where the @! comes in, basically it's a reference back to the database where the query originated from

For example, create a test database link, even to the same database, and run this:

alter system flush shared_pool;
select sysdate from dual@myself;
select sql_text from gv$sql where sql_fulltext like '%@!%';

SQL_TEXT
--------
SELECT SYSDATE@! FROM "DUAL" "A1"
like image 96
James Avatar answered Nov 06 '22 02:11

James