Use Sql*plus to build perfect Excel or HTML output

Source: Internet
Author: User

With Sql*plus we can build friendly outputs to meet the needs of diverse users.
In this example, a simple example is presented for the output of xls,html two format files via Sql*plus.
First create two scripts:
1.main.sql
To set the environment, invoke the specific function script
2. Function Script-get_tables.sql
Scripts to implement specific functions
With these two scripts, you can avoid redundant information in spool, as a reference to:
How to remove redundant information from spool in Sqlplus

Examples are as follows:
1.main.sql script:

[Email protected] utl_file]$ more Main.sqlset linesize, set term off verify off feedback off pagesize 999 Set markup h Tml on Entmap in spool on Preformat offspool Tables.xls@get_tables.sqlspool offexit


2.get_tables.sql script:

[Email protected] utl_file]$ more Get_tables.sql Select Owner,table_name,tablespace_name,blocks,last_analyzedfrom All_tables ORDER by 1, 2;


3. Execute and get output:

[[email protected] utl_file]$ sqlplus "/As SYSDBA" @mainSQL *plus:release 9.2.0.4.0-production on Mon Apr 25 10:30:11 2 005Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved. Connected to:oracle9i Enterprise Edition release 9.2.0.4.0-productionwith the partitioning optionjserver release 9.2.0.4 .0-productiondisconnected from Oracle9i Enterprise Edition Release 9.2.0.4.0-productionwith the partitioning optionjse RVer Release 9.2.0.4.0-production[[email protected] utl_file]$ ls-l tables.xls-rw-r--r--    1 Oracle   DBA         


Output as XLS file here, we can see the output effect:

To change the Main.sql script, spool Tables.xls to spool tables.htm, we can get the output of the HTM format, such as:

Use Sql*plus to build perfect Excel or HTML output

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.