How to execute .SQL files from console

Very easy, just log in into sqlplus and type as follows if you are in the same path as your file:

SQL > @file_name.sql

If you are not in the same path as your file, you should type as follows:

SQL > @/path/to/file_name.sql

What if I need to pass a parameter? Well, not a problem, just type as follows:

SQL > @file_name.sql param1 param2

or

SQL > @/path/to/file_name.sql param1 param2

Sources

  • http://www.techonthenet.com/oracle/questions/script.php
  • http://stackoverflow.com/questions/18620893/how-do-i-pass-arguments-to-a-pl-sql-script-on-command-line-with-sqlplus

Leave a Comment

Your email address will not be published. Required fields are marked *