Sqlplus command line tool formatting command

Source: Internet
Author: User

At work, there are often no third-party SQL tools such as sqplus developer, which must be directly queried on the server using sqlplus.

For example, to view the SGA value of the system parameter;

The execution result is as follows:

 

  1. [Gysy01 @ Oracle]/Oracle> sqlplus "/
    Sysdba"

  2. SQL * Plus: Release 11.1.0.7.0-production on Thursday
    February 17 17:35:16 2011

  3. Copyright (c) 1982,200 8, Oracle. All rights
    Reserved.


  4. Connected:
  5. Oracle Database 11g Enterprise Edition Release 11.1.0.7.0-64bit
    Production
  6. With the partitioning, real Application Clusters, OLAP, Data Mining
  7. And real application testing options

  8. SQL> show parameter SGA;

  9. Name type
  10. ----------------------------------------------------------

  11. Value
  12. ------------------------------

  13. Lock_sga Boolean
  14. False
  15. Pre_page_sga Boolean
  16. False
  17. Sga_max_size big integer
  18. 4G
  19. Sga_target big integer
  20. 3G
  21. SQL>

We can see that the serial problem is very serious. In this case, you need to set the number of line characters. The following figure shows the Parameter Modification result.

 

 

  1. SQL> set linesize 1000
  2. SQL> show parameter SGA;

  3. Name type value
  4. ----------------------------------------------------------------------------------------

  5. Lock_sga Boolean false
  6. Pre_page_sga Boolean false
  7. Sga_max_size big integer 4G
  8. Sga_target big integer 3G
  9. SQL>

Below are some common parameter descriptions, which use linesize, pagesize, and rowwidth parameters.

 

SQL> set colsep ''; //-domain output Separator

SQL> set echo off; // displays each SQL command in the Start script. The default value is on.

SQL> set echo on // set whether to display the statement when running the command

SQL> set feedback on; // The "XX rows selected" is displayed"

SQL> set feedback off; // display the number of records processed by this SQL command. The default value is on.

SQL> set heading off; // output domain title, on by default

SQL> set pagesize 0; // number of output lines per page. The default value is 24. To avoid paging, you can set the value to 0.

SQL> set linesize 80; // output the number of characters in a row. The default value is 80.

SQL> set numwidth 12; // The length of the output number field. The default value is 10.

SQL> set termout off; // displays the execution results of commands in the script. The default value is on.

SQL> set trimout on; // Remove trailing spaces in each row of the standard output. The default value is off.

SQL> set trimspool on; // remove the trailing space of each row from the redirection (Spool) output. The default value is off.

SQL> set serveroutput on; // set to allow display of output similar to dbms_output

SQL> set timing on; // set to display "time in use: XXXX"

SQL> set autotrace on-; // set to allow analysis of executed SQL statements

Set verify off // you can close or open the prompt to confirm the display of information old 1 and new 1.

 

Export result to text:

Spool <spool_flat_file>

Example: spool D: \ spool_flatquery.txt

In this way, SQL * Plus will specify all output and on-screen commands to this file.

Execute the query output. At this time, the system does not save the result to the file, but saves it to the buffer.

After the query is complete, close the file. Command Format: 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.