Use Sqlplus to output only data to a text file instance

Source: Internet
Author: User
Tags format query sqlplus
The data is stored as a file (such as: create_csv.sql) and then executed in Sqlplus to output the data to the specified file.
--Number of characters per line, max value is 999
Set Linesize 800
--This parameter sets the number of rows per page output, including Ttitle (header), btitle (bottom caption), column (column headings), and blank lines. N=0 indicates no new page is generated
Set pagesize 0
--Column Settings
--col username format A4
--col a format 999,999,999
--The headings for each column, including text and underscores, are displayed on the results report. Prohibit output column headers
Set Heading off
--At the end of the query, give the number of records of the query results. Suppress the last line of count feedback
Set Feedback off
--whether the command itself is displayed on the screen when the command file is executed
Set echo off
--
Set Termout off
--empty extra space, such as: Linesize too long
Set Trimout on
Set Trimspool on
--Production Data command
Spool E:\output cott_spool_emp.csv;
Select Empno| | ', ' | | ename| | ', ' | | job| | ', ' | | mgr| | ', ' | | hiredate| | ', ' | | SAL from EMP;
Spool off;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.