SQL*Plus
User's Guide and Reference
Release 8.1.7 Part Number A82950-01 |
|
This chapter explains how to access SQL*Plus from the operating system prompt, and discusses the following topics:
You use the SQLPLUS command at the operating system prompt
to start SQL*Plus:
SQLPLUS [ [Options] [Logon] [Start] ]where:
Options |
has the following syntax:
- | -? | [ [-M[ARKUP]] markup_option] [-R[ESTRICT] {1|2|3}] [-S[ILENT]] ] |
|
and markup_option has the following syntax:
HTML [ON|OFF] [HEAD text] [BODY text] [TABLE text] [ENTMAP {ON|OFF}] [SPOOL {ON|OFF}] [PRE[FORMAT] {ON|OFF}] |
Logon |
has the following syntax:
{username[/password][@connect_identifier | / } [AS {SYSOPER|SYSDBA}] | /NOLOG |
Start |
has the following syntax:
@file_name[.ext] [arg ...] |
You have the option of entering logon. If you do not
specify logon and do specify start, SQL*Plus assumes that
the first line of the command file contains a valid logon. If neither start
nor logon are specified, SQL*Plus prompts for logon information.
The following sections contain descriptions of SQLPLUS command
terms:
You can use the MARKUP option to generate either a complete
stand alone web page from your query or script, or to generate HTML output
which can be embedded in a web page. MARKUP currently supports HTML 3.2.
Use SQLPLUS -MARKUP HTML ON or SET MARKUP HTML ON SPOOL
ON to produce standalone web pages. SQL*Plus will generate complete HTML
pages automatically encapsulated with <HTML> and <BODY> tags. The
HTML tags in a spool file are closed when SPOOL OFF is executed or SQL*Plus
exits.
The -SILENT and -RESTRICT command line options may be useful
when used in conjunction with -MARKUP.
You can use SET MARKUP HTML ON SPOOL OFF to generate HTML
output suitable for embedding in an existing web page. Output generated
this way has no <HTML> or <BODY> tags.
In this release, you can use MARKUP HTML ON to produce HTML
output in either the <PRE> tag or in an HTML table. Output to a table
uses standard HTML <TABLE>, <TR> and <TD> tags to automatically
encode the rows and columns resulting from a query. Output to an HTML table
is now the default behavior when the HTML option is set ON. You can generate
output using HTML <PRE> tags by setting PREFORMAT ON. Use the SHOW MARKUP
command to view the status of MARKUP options.
The SQLPLUS -MARKUP command has the same options and functionality
as the SET MARKUP command. These options are described in this section.
For information on the SET MARKUP command, see the SET
command in Chapter 8.
Note: Depending on your operating system, the complete -MARKUP
clause for the SQLPLUS command may need to be contained in quotes.
|
HTML is a mandatory MARKUP argument which specifies that
the type of output to be generated is HTML. The optional HTML arguments,
ON and OFF, specify whether or not to generate HTML output. The default
is OFF.
MARKUP HTML ON generates HTML output using the specified
MARKUP options, or in the case of SET MARKUP, options set by previous SET
MARKUP HTML commands in the current session.
You can turn HTML output ON and OFF as required during a
session. The default is OFF.
You enable the writing of HTML output with the MARKUP option,
SPOOL ON, and you subsequently initiate writing output to a spool file
with the SQL*Plus command, SPOOL filename. See SPOOL
{ON|OFF} below, and the SPOOL command
in Chapter 8 for more information.
Note: SQL*Plus 8.1.7 implements HTML tables as the default HTML
output. More HTML tags may be implemented in future releases.
|
<TITLE>SQL*Plus Report</TITLE>
If text includes spaces, it must be enclosed in quotes. SQL*Plus does not test this free text entry for HTML validity. You must ensure that the text you enter is valid for the HTML <HEAD> tag. This gives you the flexibility to customize output for your browser or special needs.
The BODY text option allows you to specify attributes for the <BODY> tag. By default, there are no attributes. If text includes spaces, it must be enclosed in quotes. SQL*Plus does not test this free text entry for HTML validity. You must ensure that the text you enter is valid for the HTML <BODY> tag. This gives you the flexibility to customize output for your browser or special needs.
The TABLE text option allows you to enter attributes
for the <TABLE> tag. You can use TABLE text to set HTML <TABLE>
tag attributes such as BORDER, CELLPADDING, CELLSPACING and WIDTH. By default,
the <TABLE> WIDTH attribute is set to 90% and the BORDER attribute is
set to 1.
If text includes spaces, it must be enclosed in quotes. SQL*Plus does not test this free text entry for HTML validity. You must ensure that the text you enter is valid for the HTML <TABLE> tag. This gives you the flexibility to customize output for your browser or special needs.
ENTMAP ON or OFF specifies whether or not SQL*Plus replaces
special characters <, >, " and & with the HTML entities <,
> " and & respectively. ENTMAP is set ON by default.
You can turn ENTMAP ON and OFF as required during a session. For example, with ENTMAP OFF, SQL*Plus screen output is:
SQL> SELECT ENAME, EMPNO 2 FROM EMP 3 WHERE SAL <= 2000;
With ENTMAP ON, SQL*Plus screen output is:
SQL> SELECT ENAME, EMPNO 2 FROM EMP 3 WHERE SAL <= 2000;
If entities are not mapped, web browsers may treat data
as invalid HTML and all subsequent output may display incorrectly. ENTMAP
OFF allows users to write their own HTML tags to customize output.
As entities in the <HEAD> and <BODY> tags are not mapped, you must ensure that valid entities are used in the MARKUP HEAD and BODY options.
Note: |
SPOOL ON or OFF specifies whether or not SQL*Plus writes
the HTML opening tags, <HTML> and <BODY>, and the closing tags, </BODY>
and </HTML>, to the start and end of each file created by the SQL*Plus
SPOOL filename command. The default is OFF.
You can turn SPOOL ON and OFF as required during a session.
SQL*Plus writes several HTML tags to the spool file when you issue the SPOOL filename command. The tags written and their default content are:
<HTML> <HEAD> <TITLE>SQL*Plus Report</TITLE> <META name="generator" content="SQL*Plus 8.1.7"> </HEAD> <BODY> When you issue any of the SQL*Plus commands: EXIT, SPOOL OFF or SPOOL filename, SQL*Plus appends the following end tags and closes the file: </BODY></HTML>
You can specify <HEAD> tag contents and <BODY> attributes using the HEAD and BODY options
PREFORMAT ON or OFF specifies whether or not SQL*Plus writes
output to the <PRE> tag or to an HTML table. The default is OFF, so
output is written to a HTML table by default. You can turn PREFORMAT ON
and OFF as required during a session.
Notes: To produce report output using the HTML <PRE> tag, you
must set PREFORMAT ON. For example:
SQLPLUS -M "HTML ON PREFORMAT ON" SET MARKUP HTML ON PREFORMAT ON |
Existing scripts that do not explicitly set PREFORMAT ON
will generate output in HTML tables. If you want output in HTML <PRE>
tags, you must set PREFORMAT ON.
Some SQL*Plus commands have different behavior when output is directed to an HTML table. Commands originally intended to format paper reports may have different meaning for reports intended for web tables:
Allows you to disable certain commands that interact with
the operating system. This is similar to disabling the same commands in
the Product User Profile (PUP) table. However, commands disabled with the
-RESTRICT option are disabled even if there is no connection to a server,
and remain disabled until SQL*Plus terminates.
If no -RESTRICT option is active, than all commands can
be used, unless disabled in the PUP table.
If -RESTRICT 3 is used, then LOGIN.SQL is not read. GLOGIN.SQL
is read but restricted commands used will fail.
Table 7-1 shows the commands disabled in each restriction
level.
Suppresses all SQL*Plus information and prompt messages,
including the command prompt, the echoing of commands, and the banner normally
displayed when you start SQL*Plus. If you omit username or password,
SQL*Plus prompts for them, but the prompts are not visible. Use SILENT
to invoke SQL*Plus within another program so that the use of SQL*Plus is
invisible to the user.
SILENT is a useful mode for creating reports for the web using the SQLPLUS -MARKUP command inside a CGI script or operating system command file. The SQL*Plus banner and prompts are suppressed and do not appear in reports created using the SILENT option.
Represent the username and password with which you wish
to start SQL*Plus and connect to Oracle. If you omit username and
password,
SQL*Plus prompts you for them.
If you omit only password, SQL*Plus prompts you for password. When prompting, SQL*Plus does not display password on your terminal screen. In silent mode, username and password prompts are not visible - your username will appear as you type it, but not your password.
Represents a default logon using operating system authentication. You cannot enter a database_specification if you use a default logon. In a default logon, SQL*Plus typically attempts to log you in using the username OPS$name, where name is your operating system username. Note that the prefix "OPS$" can be set to any other string of text. For example, you may wish to change the settings in your INIT.ORA parameters file to LOGONname or USERIDname. See the Oracle8i Administrator's Guide for information about operating system authentication.
SQLPLUS "/ AS SYSDBA" SQLPLUS "SYSTEM/MANAGER AS SYSOPER"
Establishes no initial connection to Oracle. Before issuing any SQL commands, you must issue a CONNECT command to establish a valid logon. Use /NOLOG when you want to have a SQL*Plus command file prompt for the username, password, or database specification. The first line of this command file is not assumed to contain a logon.
SQL*Plus supports a Site Profile, a SQL*Plus command file
created by the database administrator. This file is generally named GLOGIN
with an extension of SQL. SQL*Plus executes this command file whenever
any user starts SQL*Plus and SQL*Plus establishes the Oracle connection.
The Site Profile allows the DBA to set up SQL*Plus environment defaults
for all users at a particular site; users cannot directly access the Site
Profile. The default name and location of the Site Profile depend on your
system. Site Profiles are described in more detail in the Oracle installation
and user's manual(s) provided for your operating system.
SQL*Plus also supports a User Profile, executed after the
Site Profile. SQL*Plus searches for a file named LOGIN with the extension
SQL in your current directory. If SQL*Plus does not find the file there,
SQL*Plus will search a system-dependent path to find the file. Some operating
systems may not support this path search.
If you fail to log in successfully to SQL*Plus because your
username or password is invalid or some other error, SQL*Plus will return
an error status equivalent to an EXIT FAILURE command. See the EXIT command
in this chapter for further information.
To start SQL*Plus with username SCOTT and password TIGER, enter
SQL> SQLPLUS SCOTT/TIGER
To start SQL*Plus, as above, and to make POLICY the default database (where POLICY is a valid Net8 database connect identifier), enter
SQL> SQLPLUS SCOTT/TIGER@POLICY
To start SQL*Plus with username SCOTT and password TIGER and run a command file named STARTUP with the extension SQL, enter
SQL> SQLPLUS SCOTT/TIGER @STARTUP
Note the space between TIGER and @STARTUP.
To start SQL*Plus with HTML ON, so that output can be viewed on a web browser, enter
SQL> SQLPLUS -M "HTML ON" SCOTT/TIGER
To start SQL*Plus with no access to the EDIT and HOST commands during the session, enter
SQL> SQLPLUS -R 1 SCOTT/TIGER
To display the syntax of the SQLPLUS command, enter
SQL> SQLPLUS -H
SQL*Plus displays the following
Usage: SQLPLUS [ [<option>] [<logon>] [<start>] ] where <option> ::= - | -? | [ [-M <o>] [-R <n>] [-S] ] <logon> ::= <username>[/<password>][@<connect_identifier>] | / |/NOLOG <start> ::= @<filename>[.<ext>] [<parameter> ...] - displays the SQL*Plus version banner and usage syntax -? displays the SQL*Plus version banner -M <o> uses HTML markup options <o> -R <n> uses restricted mode <n> -S uses silent mode
To access online help for SQL*Plus commands, you can type HELP followed by the command name at the SQL command prompt. For example:
SQL> HELP ACCEPT
To display a list of SQL*Plus commands, type HELP followed by either TOPICS or INDEX. HELP TOPICS displays a single column list of SQL*Plus commands. HELP INDEX displays a four column list of SQL*Plus commands which usually fits in a single screen. For example:
SQL> HELP INDEX
If you get a response that help is unavailable, consult your
database administrator. See the HELP command
in Chapter 8 for more information.
|
![]() Copyright © 2000 Oracle Corporation. All Rights Reserved. |
|