In sqlplus, how does one save all your operations and Result Records to your specified file?

Source: Internet
Author: User

In sqlplus, how does one save all your operations and Result Records to your specified file?

[In sqlplus operations, we often want to record the SQL statements we write and modify the log or result information]

[First] You must connect to the oralce database normally.

[Then]

After you log on to the oralce database with your specified user

SQL>spool d:\oracle.txt;
After the keyword spool is used in the preceding command, you need to save all the operations you want to perform and the format you want to save.

............

When you are not planning to operate the database, or you are planning to disable the sqlplus client tool, then you will see the file record you want to save in the path you just set.

SQL>spool d:\oracle.txt;

[About spool commands]

Spool is a sqlplus command and can only be used in sqlplus.

[Spool settings-common use]

Set pagesize 0;

Ps: {number of pages in each output line. The default value is 0. To avoid paging, you can set the value to 0. However, in some oracle versions, this parameter is not valid and will be processed as needed}

Set colsep '';

Ps: {output domain separator}

Set echo off;

Ps: {each command in the start script is displayed. The default value is on}

Set feedback off;

Ps: {display the number of records processed by this SQL command. The default value is on}

Set heading off;

Ps: {output domain title, on by default}

Set linesize 80;

Ps; {number of characters in each line output, 80 by default}

Set trimout on;

Ps: {Remove trailing spaces for each row of the standard output. The default value is off}

Set termout off;

Ps: {display the execution result of commands in the script}


How can pl \ SQL or SQL plus save query results?

You can use the spoolcommand to create a. txt file on the hard drive.
Spool X: \ A.txt;
Select * from table;
Spool off;

In this way, the query result is saved to X: \ A.txt;

Create the following SQL statement and save the query result to the candidate folder.

Because no table structure is provided, only Chinese characters can be used instead.
1. select * from student table
2. select name, class from student table where gender = 'female'
3. The table structure is unknown and cannot be queried.
4. select student ID, name from instructor table where name like = 'Li %'
5. select * from instructor table where title = 'Professor'
6. select * from instructor table where start time <'2014-1-1'
7. The structure of the unknown table may be queried by multiple tables.
8. Unknown table structure
9. insert into professional table values (004, 'account ')
10. update professional table set professional code = 05 where professional code = 04
11. delete from professional table where major = 'account'
12. Multi-Table query, unknown table structure
 

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.