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

Walkerbo
  • 545
  • 8
  • 16

2 Answers2

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
Community
  • 1
  • 1
Atilla Ozgur
  • 14,339
  • 3
  • 49
  • 69
  • 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. – Walkerbo Apr 01 '15 at 22:15
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.

  • 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. – NELSON JOSEPH Nov 30 '22 at 22:30