3.1sql*plusinteracting with the database
A tool used primarily for database querying and data processing.
3.2sql*plusRun environment settings3.2.1SETCommand Overview
The user can use the Set command to set the sql*plus Environment andThe syntax format of theset command:
SET system_variable Value
System_variable: variable name
Value: Variable values
SET Common variable name, optional value and description: See book p55~p56.
3.2.2UseSETcommand set Run environment
1) Pagesize variable:set Pagesize value.
2) Newpage variable:set Newpage value. (show NewPage)
3) linesize variable:set linesize value. (showline)
4) Pause variable:Set Pause value(off,on,text )
3.3CommonSql*plusCommand3.3.1HELPCommand
Help|? [TOPIC]
For example: Helpstartup.
If the user cannot remember the command you want to use, you can use the Help index command to view the list of sql*plus commands.
3.3.2DESCRIBECommand
Used to query tables and view Structures , and to query specifications for PL/SQL objects such as procedures, functions, packages, and so on . Command syntax format:
Desc[ribe] object_name;
3.3.3SPOOLCommand
The SPOOL command outputs the results of the query to the specified file so that the output can be saved for easy printing. The syntax format for the SPOOL command is as follows:
spo[ol][file_name[.ext][cre[ate]|[ rep[lace]| app[end]]| Off| Out]
The parameter file_name Specifies the offline file name, and the default file extension is LST.
1) cre[ate]: represents the default state of creating a new offline file.
2) Rep[lace]: represents an alternative to an existing offline file.
3) App[end]: Indicates that the offline content is appended to an existing offline file.
4) off| Out: Indicates that the SPOOL output is turned off .
3.3.4Other common commands
1) DEFINE command
2) SHOW command
3) EDIT command
4) SAVE command
5) GET command
6) START and @ command
3.4Formatting Query Results3.4.1COLUMNCommand
This command enables formatting of query results, setting column widths, and reformatting column headings. Syntax format:
Col[umn][column_name][alias][option]
1) column_name: used to specify the name of the column to set.
2) Alias: used to specify the alias of the column, you can set the English column headings as Chinese characters.
3) Option: used to specify the display format for a column
3.4.2TTITLEand theBttleCommand
These two commands are used to set the top and bottom headings for each page when printing.
3.sql*plus command