0

I am learning SQL at the moment, and am using Oracle SQL Developer.

Right now I am having an issue with the spool command.

I insert the file path and name the file but I keep getting an "unknown command" error.

spool C:\Users\user\Desktop\AAA_Task1\output.txt
set echo on
--drop table TESTTABLE;
create table TESTTABLE (TestCol int);
set echo off
spool off

I alternate between the create and drop statements for each test.

I run the and the table is created or dropped correctly, but I get a line one error "Unknown Command" and no text file is created.

I have attached a picture of a test command and the error.

If someone could point me in the right direction I would be grateful.

Oracle SQL Developer - Spooling issue

0

2 Answers 2

3

There is difference between run script and run statement, see here. Use following commands and run script.

spool 'C:\Users\user\Desktop\AAA_Task1\output.txt'
set echo on
--drop table TESTTABLE;
create table TESTTABLE (TestCol int);
set echo off
spool off
Sign up to request clarification or add additional context in comments.

1 Comment

Doh So I simply just needed to wrap the file path in quotation marks. I cant believe I missed that. Thank you so much for the speedy reply.
0

Making the file path in quotes did not work for me in the Oracle database.

spool data.txt
set echo on
Query -- the query
set echo off
spool off

this will save the query and output to the data.txt file in the "C:\Users\NELSON JOSEPH\AppData\Roaming\SQL Developer\data.txt" in this location likewise username varies for others.

1 Comment

When you save the .sql file to any location after that when you run the script the spooled txt file will be in that location.

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.