Summary of oracle script execution commands

Source: Internet
Author: User
1. execute an SQL script file sqlplususerpass@servicenamefile_name. SQL or SQLstartfile_names or SQL @ file_name we can save multiple SQL statements in a text file so that when you want to execute all the SQL statements in this file, use any of the preceding commands, which is similar to batch processing in dos. @

1. run an SQL script file sqlplus user/pass@servicenamefile_name. SQL or SQLstart file_names or SQL @ file_name we can save multiple SQL statements in a text file, in this way, when you want to execute all the SQL statements in this file, you can use any of the following commands, which is similar to batch processing in dos. @

1. Execute an SQL script file
Sqlplus user/pass @ servicename Or
SQL> start file_names
Or
SQL> @ file_name
We can save multiple SQL statements in a text file, so that when we want to execute all the SQL statements in this file, we can use any of the following commands, which is similar to batch processing in dos.
What is the difference between @ and?
@ Equals to the start command, used to run an SQL script file.
@ Command to call the script file in the current directory, or specify the full path, or you can use the SQLPATH environment variable to search for the script file. This command is generally used to specify the full path of the file to be executed, otherwise the specified file is read from the default path (specified by the SQLPATH variable.
@ Is used in the SQL script file to indicate that the SQL script file executed with @ is in the same directory as the file where @ is located, instead of specifying the full path of the SQL script file to be executed, or finding the SQL script file from the path specified by the SQLPATH environment variable, this command is generally used in the script file.
For example, in the c: temp directory, files start. SQL and nest_start. SQL are available. The content of the start. SQL script file is:
@ Nest_start. SQL--equivalent to @ c: tempnest_start. SQL
In SQL * plus, run the following command:
SQL> @ c: tempstart. SQL
2. Run the last SQL statement again.
SQL>/
3. output the displayed content to the specified file.
SQL> SPOOL file_name
All content on the screen is input to this file, including the SQL statement you entered.
Generally, we use the SPOOL method to export the tables in the database as text files in two ways, as shown below:
Method 1: script in the following format
Set colsep '|';-set | column Separator
Set trimspool on;
Set linesize 120;
Set pagesize 2000;
Set newpage 1;
Set heading off;
Set term off;
Set num 18;
Set feedback off;
Spool path + file name;
Select * from tablename;
Spool off;
Method 2: Use the following script
Set trimspool on
Set linesize 120
Set pagesize 2000
Set newpage 1
Set heading off
Set term off
Spool path + file name
Select col1 | ',' | col2 | ',' | col3 | ',' | col4 | '...' from tablename;
Spool off

Original article address: Summary of oracle script execution commands. Thanks to the original author for sharing.

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.