Use SQLPLUS only output data to instances of text files

xiaoxiao2021-03-06  110

Make the following contents (such as: create_csv.sql), then execute in SQLPLUS, output data to the specified file.

- Number of characters per row, Max Value IS 999

Set Linesize 800

- This parameter sets the number of rows output per page, including TTILE (head title), BTITLE, Column (column header) and blank line. n = 0 means not generating a new page

SET PAGESIZE 0

- Settings

--COL UserName Format A4

--Col A Format 999, 999, 999

- The title of each column (including text and underscore) is displayed on the results report. Prohibited output column header

Set heading off

- At the end of the query, the number of records of the query results are given. Prohibit display of the last row count feedback

Set feedback off

- When executing a command file, whether the command itself is displayed on the screen

Set echo off

-

Set Termout Off

- Empty extra spaces, such as: LineSize is too long

Set trimout on

Set trimspool on

- Production data command

Spool E: /output/scott_spool_emp.csv;

SELECT Empno || ',' || Ename || ',' || Job || ',' || Mgr || ',' || || || || Sal from EMP

Spool OFF;

转载请注明原文地址:https://www.9cbs.com/read-104354.html

New Post(0)