Useful shortcuts for vi editor

Showing posts with label linesize. Show all posts
Showing posts with label linesize. Show all posts

Friday, 6 April 2018

How to use SPOOL command in Oracle?

WINDOWS
e.g.
SQL> 
sqlplus / as sysdba;

SQL>
SET LINESIZE 200;
SET PAGESIZE 100;

-- define a output file for writing
SPOOL 'C:\output_SQL.txt'; 

  SELECT owner,
         object_name,
         created,
         timestamp
    FROM DBA_OBJECTS
   WHERE STATUS = 'INVALID'
ORDER BY OBJECT_NAME;

-- stop to write
SPOOL OFF; 

LINUX
e.g.
SQL> 
sqlplus / as sysdba;

SQL>
SET LINESIZE 200;
SET PAGESIZE 100;

--define a output file for writing
SPOOL '/tmp/output_SQL.txt'; 

  SELECT owner,
         object_name,
         created,
         timestamp
    FROM DBA_OBJECTS
   WHERE STATUS = 'INVALID'
ORDER BY OBJECT_NAME;

-- stop to write
SPOOL OFF; 

-> to see output file
$ cat /tmp/output_SQL.txt