I found this line in a sql code:
@../../sql_scripts/create_tables.sql
What does it do? I know that @@file.sql means that file.sql is run and @ could be used when we want to supply parameter values later, but here I have @ followed by a filename. I know that there is a similar question but it covers only @ in queries.
Here the @ is not part of the SQL language. It is likely a command for the SQL interpreter which is probably Oracle SQL*Plus.
SQL*Plus has many single-character commands like @ or / (which executes buffered SQL), ; which can be puzzling when you encounter them in an .sql file.
@ is documented here in Oracle 9i documentation. There you will see the differences with @@.
documentation for Oracle 11g Release 2, click Next section for @@ reference.
The @ allows you to import another script into the sql script you're running in SQL*Plus.
For example, this executes the contents of otherscript.sql at the specified point:
PROMPT about to run other script
@otherscript.sql
PROMPT finished running other script
Another example, this inserts the contents of another file into the middle of a statement to be executed in SQL*Plus:
SELECT * FROM mytable WHERE
@predicates_for_mytable.sql
AND bla = 1;
The only condition is that @ must appear at the 1st character on the line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With