50

I have written couple of sql scripts in a text file and saved them with a .sql extension. I want to execute these scripts in the sql plus terminal without having to manually type the standalone sql scripts, but i'm struggling with it. If someone could list out the steps involved I would be very grateful.

I could copy and paste those scripts in the terminal but that is not what I am looking at, I want to see if there is a way to provide the path to the scripts in the sql plus editor.

3
  • they're just text. if nothing else, cut&paste them. Commented Aug 19, 2016 at 16:33
  • I could do that , but what I'm looking at is to execute those files by providing the class path to which the files exist. I'm just trying to see if there is a way to do that. Added that poiint in the question @MarcB Commented Aug 19, 2016 at 16:34
  • 2
    This is covered in the SQL*Plus documentation. Commented Aug 19, 2016 at 17:43

2 Answers 2

85

If your filename is myQueries.sql, just type

SQL>@/path/to/my/query/myQueries.sql
SQL>/
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks a lot @bhattdon . This was exactly what I was looking for.
that simple, second row saved me from a lot of trouble ! thanks !
For those who wonder what the second row is about (/(slash)): Executes the most recently executed SQL command or PL/SQL block which is stored in the SQL buffer. The buffer has no command history and does not record SQL*Plus commands.
0

if you see error like SP2-0023 String not found

try

SQL>@"Path/query.sql"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.