Reputation: 1065
We have some migration scripts that use @@filename
and @filename
in SQL*Plus scripts to call another file. (e.g. to call thesql.sql its @@thesql
)
I want to understand the difference between the @
and the @@
.
I have found many answers explaining @filename
will call a file from the current directory but nothing about the double @.
FYI: @@filename
and @@filename.sql
both seem to work because it assumes the extension
Upvotes: 2
Views: 4326
Reputation: 1
I just found that START
command, like most other SQL*Plus commands, can be continued on the next line after you put a dash -
at the end of the previous line (useful when a script takes many or long arguments). However, this does not work for @
or @@
- at least not in SQL*Plus version 19.3.
Command line continuation works for both START
and @
in SQLcl (command line tool from SQL Developer).
Upvotes: 0
Reputation: 1065
I ended up finding the answer on https://www.orafaq.com/wiki/SQL*Plus_FAQ#What_is_the_difference_between_.40_and_.40.40.3F
What is the difference between @ and @@?
The @ (at symbol) is equivalent to the START command and is used to run SQL*Plus command scripts.
SQL> @myscript.sql
A single @ symbol runs a script in the current directory (or one specified with a full or relative path, or one that is found in your SQLPATH or ORACLE_PATH).
@@ will start a sqlplus script that is in the same directory as the script that called it (relative to the directory of the current script). This is normally used for nested command files. This technique is commonly used by scripts that call subscripts in the ?/rdbms/admin directory. The @@ reference does not support relative directory references such as @@dir/file.sql or @@./file.sql.
Upvotes: 4