Skip to Main Content
  • Questions
  • How to handle spaces in directory while spooling output from oracle query

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question.

Asked: March 21, 2016 - 12:36 pm UTC

Last updated: March 21, 2016 - 4:38 pm UTC

Version: 12.0.1

Viewed 10K+ times! This question is

You Asked

The directory name is created in script at run time. I need to handle the spaces in SPOOL.
Please suggest a way

and Chris said...

Just place the path and file name in double quotes:

c:\>mkdir "with spaces"

c:\>sqlplus chris/chris@db

SQL*Plus: Release 12.1.0.2.0 Production on Mon Mar 21 16:36:23 2016

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Last Successful login time: Mon Mar 21 2016 16:33:44 +00:00

Connected to:
Oracle Database 12c EE Extreme Perf Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Advanced Analytics
and Real Application Testing options

SQL> spool "c:\with spaces\out.log"
SQL> select 'just quote it!' from dual;

'JUSTQUOTEIT!'
--------------
just quote it!

Elapsed: 00:00:00.33
SQL> spool off
SQL> exit
Disconnected from Oracle Database 12c EE Extreme Perf Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Advanced Analytics
and Real Application Testing options

c:\>type "c:\with spaces\out.log"
SQL> select 'just quote it!' from dual;

'JUSTQUOTEIT!'

--------------

just quote it!


Elapsed: 00:00:00.33
SQL> spool off


Is this answer out of date? If it is, please let us know via a Comment

More to Explore

VLDB

If you are new to partitioning, check out Connor McDonald's introduction series here.

VLDB

Documentation set on VLDB and Partitioning.