Sqlplus command User Guide

Source: Internet
Author: User
Sqlplus command User Guide

Sqlplus command User Guide (1)
Anyone familiar with Oracle knows that SQL plus is an important tool for dealing with Oracle. SQL plus itself has many commands that can help us do many things, including generating standardized reports and providing human-computer interaction. Below, I will briefly describe it for your reference:
1. Help commands
Help helps us find the usage of each SQL plus command
Example:
SQL> help accept

Accept
------

Reads a line of input and stores it in a given user variable.

ACC [EPT] variable [num [ber] | char | date] [for [Mat] format]
[DEF [ault] default] [prompt text | nopr [OMPT] [hide]

Two sqlplus commands for Human-Computer Interaction
In sqlplus, user input is acceptable. The most common commands are:
(1) accept
Accept the data of the entire row.
Syntax: ACC [EPT] variable [num [ber] | char | date] [for [Mat] format]
[DEF [ault] default] [prompt text | nopr [OMPT] [hide]
Example:
Angular 1. SQL, find the employee whose salary is greater than the input amount.
Set feedback off
Set pause off
Accept Sal number prompt 'Please input salary (weekly ):'
Select employee_id, last_name, first_name, salary from employee
Where salary> [$ Sal]
Run in sqlplus
SQL> @ C:/1. SQL
Please input salary (weekly): 1000
Old 2: Where salary> & Sal
New 1: Where salary> 1000

Employee_id last_name first_name salary
---------------------------------------------------------------------------
7499 Allen Kevin 1600
7505 Doyle Jean 2850
7506 Dennis Lynn 2750
7507 Baker Leslie 2200
7521 ward Cynthia 1250
7555 Peters Daniel 1250
7557 Shaw Karen 1250
7560 Duncan Sarah 1250
7564 Lange Gregory 1250
7566 Jones Terry 2975
7569 Alberta Chris 3000
Note:
① Accept accepts a row of input, and stores the input data to the variable according to the specified type (if it does not exist, it will automatically create one.
② Fomrat is used to specify the input data format. For example, you can specify '192. 99' for numbers and 'a10' for characters'
③ If the type is Char, the maximum length is 240.

(2) Prompt
Output prompt information.
Syntax: Pro [MPT] [text]
Example:
SQL> prompt Hello, world
Hello, world
(3) pause
Output a line of information and wait for the user to enter the carriage return.
Syntax: Pau [se] [text]
Example:
SQL> pause please press [Return]
Please press [Return]

SQL>

Edit command
The last SQL statement sent using SQL plus is stored in a data buffer zone of SQL plus. The sqlplus command is not included and can be edited using the editing command.
(1 )/
Execute the SQL statement again.
(2) append
Append characters in the command buffer.
Example:
SQL> select * From tab;
....
SQL> A where tabtype = 'view'
1 * select * From tabwhere tabtype = 'view'
SQL>/

Tname tabtype clusterid
-----------------------------------------------
Plsql_profiler_grand_total View
Plsql_profiler_lines_cross_run View
Plsql_profiler_notexec_lines View
Plsql_profiler_units_cross_run View
Sales View

(3) list or;
List the content in the buffer. A list can list the content of a row, while a list is all.
Example:
SQL>;
1 select * From tab where tabtype = 'view'
2 * order by tname
SQL> L 2
2 * order by tname
(4) Input
Add a line of content
Example:
SQL> I order by tname
SQL> L
1 select * From tab where tabtype = 'view'
2 * order by tname
(5) Change
Replace the content of the first ship to the current line with the new content,
Syntax: C [hange] sepchar old [sepchar [New [sepchar]
Example:
SQL> L
1 * select * from employee where salary> 1000 and salary <2000
SQL> C/salary/Sal
1 * select * from employee where SAL> 1000 and salary <2000
Note: When there are two rows in the buffer, use C to replace the content in the last row.
(6) Edit
In the specified text editor, edit the buffer content. In Windows, the default value is notepad.
(7) Spool
Specify the output result to a file, a bit like the one in the doscommand>
SPO [Ol] [file_name [. Ext] | off | out]
SQL> spool C:/1.txt
SQL> select * From tab;
SQL> spool off

4. execute commands
(1 )@
Load the angular and run it.
Example:
SQL> @ C:/1. SQL
(2) Execute
Run the PL/SQL process and package.

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.