SPOOL query result to a file : SPOOL « SQL Plus « Oracle PL / SQL






SPOOL query result to a file

   
SQL>
SQL> BTITLE SKIP 2 CENTER 'Page  ' SQL.PNO
SQL> BREAK ON table_name SKIP 1
SQL> COLUMN table_name  FORMAT A20    HEADING 'Table'
SQL> COLUMN column_name FORMAT A22    HEADING 'Column'
SQL> COLUMN data_type   FORMAT A10    HEADING 'Data|Type'
SQL> COLUMN data_length FORMAT 999999 HEADING 'Length'
SQL> COLUMN data_scale  FORMAT 99999  HEADING 'Scale'
SQL> COLUMN nullable    FORMAT A5     HEADING 'Null'
SQL>
SQL> SPOOL 4_1.lis
SQL> SELECT table_name, column_name, data_type,
  2         DECODE(data_length, 22, data_precision,
  3                data_length) data_length,
  4         data_scale, nullable
  5  FROM   user_tab_columns
  6  where  rownum < 50
  7  ORDER BY table_name, column_id;

no rows selected

SQL> SPOOL OFF
SQL>
SQL> SPOOL OFF
not spooling currently
SQL>

   
    
  








Related examples in the same category

1.spool to a file with text string concatenation
2.Spooling files on and off
3.spool to report.txt replace
4.Extracts data from the emp table and writes it to a text file in a comma-delimited format