Oralce SQLPlus and formatted output spool output to a file in a shell script

Source: Internet
Author: User
Tags sqlplus

http://blog.csdn.net/gyanp/article/details/7903056

1) Format adjustment has the following parameters

Set echo on/off displays the commands that need to be executed in the script
Set feedback on/off indicates how many rows are returned after the select result
Set linesize n Sets the maximum number of characters to be displayed on a line, preceded by the fact that N is too large, resulting in a blank line between rows and rows
Set Termout whether the results are printed on the screen when the script is executed, and if spool to the file can be turned off
Set heading on/off displays the column name of the query result, if set to off, will be replaced with a blank line, if you want to remove the blank line, you can use set pagesize 0
Set pagesize n Sets the number of rows per page, set N to 0 to not show all headings, page breaks, titles, the initial blank line, and Other formatting information
Set Trimspool on/off when spool to a file, whether to remove the output results of the end of the line or white space characters, the preceding interlaced can be removed with this parameter, and the parameter corresponds to the Trimout, which is used for screen output
Set trimout on/off to remove whitespace characters at the end of the output line on the screen

Set space on/Off output column spacing setting

2) If you need to automatically adjust these formats sqlplus the next time you start, you can save the above settings to the $oracle_home/sqlplus/admin/glogin.sql file

3) How to redirect output to a file

Spool/tmp/sqlplus.output.txt

SELECT * from dual;

Spool off (the output is only visible in the output file if the output is turned off)

4) Column type

Col column_name Format A50 (set column_name to 50 characters justifies)

Col column_name (Display columnar format)

Col column_name noprint (hidden column)

CLEAR COLUMNS (Sets the display property of all columns to the default value)

Break (shows the setting for break)
CLEAR BREAKS (delete break's settings)

Oralce SQLPlus and formatted output spool output to a file in a shell script

Related Article

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.