Skip Headers

SQL*Plus® User's Guide and Reference
Release 10.1

Part Number B12170-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Feedback

Go to previous page
Previous
Go to next page
Next
View PDF

4 Starting SQL*Plus

This chapter describes how to start, login, and connect to a database, how to get help, and how to exit SQL*Plus.

Specific topics discussed are:

Login Username and Password

When you start SQL*Plus, you need a username and password to login to an Oracle Database schema. Your username and password identify you as an authorized user of the Oracle Database schema.

The database administrator (DBA) is responsible for creating your database account with the necessary privileges and giving you the username and password that enables you to access your account.

Default logins are created and you are prompted for associated passwords during Oracle Database installation. Some of the default login usernames created are:

Logins are created and displayed in messages during Oracle Database installation.

For further information about the default logins, see the Oracle Database Administrator's Guide.

Once you have logged in, you can connect under a different username with the SQL*Plus CONNECT command. The username and password must be valid for the database. For example, to connect the username TODD to the default database using the password FOX, you could enter

CONNECT TODD/FOX

In the command-line interface, if you omit the username and password, SQL*Plus prompts you for them. You also have the option of typing only the username following CONNECT and omitting the password (SQL*Plus then prompts for the password). Because CONNECT first disconnects you from your current database, you will be left unconnected to any database if you use an invalid username and password in your CONNECT command.

If you log on or connect as a user whose account has expired, you are prompted to change your password before you can connect.

If an account is locked, a message is displayed and connection as this user is not permitted until the account is unlocked by your DBA.

You can use the DISCONNECT command to disconnect from a database without leaving SQL*Plus.

Changing your Password

In the command-line interface, you can change your password with the PASSWORD command. See "PASSWORD".

Changing Your Password in iSQL*Plus

You can change your Oracle Database account password in the Change Password screen. If you have logged in with DBA privileges, you can change the password of other users. You access the Change Password screen from the Preferences screen.

Description of prefs_password.gif follows
Description of the illustration prefs_password.gif

Username:

Enter your Oracle Database account username.

Old password:

Enter your current Oracle Database account password.

New password:

Enter your new password.

Retype new password:

Enter your new password again to make sure you have entered it correctly.

Apply

Click the Apply button to change the password for your Oracle Database account.

Cancel

Click the Cancel button to clear the screen without changing your password.

Expired Password

In the command-line interface, if your password has expired, SQL*Plus prompts you to change it when you attempt to log in. You are logged in once you successfully change your password.

Expired Password Screen in iSQL*Plus

If your password has expired, the Expired Password screen is automatically displayed when you attempt to log in. Fill out the fields on the Expired Password screen as you would for the Change Password screen.

You are logged in once you successfully change your password. If you click the Cancel button, you are returned to the Login screen.

Description of password_expired.gif follows
Description of the illustration password_expired.gif

Connecting to a Database

You must connect to an Oracle Database (instance) before you can query or modify data in that database. You can connect to the default database and to other databases accessible through your network. To connect to another database over a network, both databases must have Oracle Net configured, and have compatible network drivers. You must enter either a connection identifier or a net service name to connect to a database other than the default.

The connection identifier or net service name is entered:

Net Service Name

Your DBA is responsible for creating the databases you use and defining net service names for them in the tnsnames.ora file. In iSQL*Plus, your DBA can also restrict the databases available to those shown in a dropdown list of net service names.

A net service name definition in the tnsnames.ora file has the syntax:

net_service_name= 
(DESCRIPTION= 
(ADDRESS=(PROTOCOL=tcp)(HOST=host)(PORT=port) )
(CONNECT_DATA= 
(SERVICE_NAME=service_name) ) ) 

To use a net service name (alias), it must have an entry in the tnsnames.ora file on the machine running SQL*Plus, or for iSQL*Plus, the machine running the iSQL*Plus Application Server. An entry in tnsnames.ora is not required if you use a connection identifier.

Example 4-1 tnsnames.ora entry for the sales database

SALES1 =
(DESCRIPTION =
(ADDRESS=(PROTOCOL=tcp)(HOST=sales-server)(PORT=1521) )
(CONNECT_DATA=
(SERVICE_NAME=sales.us.acme.com) ) )

Example 4-2 Start a command-line session to the sales database using the net service name

SQLPLUS hr/password@SALES1

See the Oracle Net Services Reference Guide and the Oracle Net Services Administrator's Guide for more information about database connections and net service name definitions.

Full Connection Identifier

Depending on your configuration, use the full connection identifier syntax like:

(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=host)(PORT=port) )
(CONNECT_DATA=
(SERVICE_NAME=service_name) ) )

You can optionally use the (INSTANCE_NAME=instance) phrase in place of the (SERVICE_NAME=service_name) phrase.

When connecting to an Oracle8i database, use the (SID=name) phrase in place of the (SERVICE_NAME=service_name) phrase.

Example 4-3 Full connection identifier for SALES1

SQLPLUS hr/password@(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=sales-server)(PORT=1521) )
(CONNECT_DATA=
(SERVICE_NAME=sales.us.acme.com) ) )

Easy Connection Identifier

The easy or abbreviated connection identifier has the syntax:

[//]host[:port][/[service_name]]

Example 4-4 Start a command-line session to the sales database using the easy connection identifier

sqlplus hr/password@sales-server:1521/sales.us.acme.com

Example 4-5 CONNECT to the sales database using the easy connection identifier

connect hr/password@sales-server:1521/sales.us.acme.com

The easy connection identifier can be used wherever you can use a full connection identifier, or a net service name. The easy syntax is less complex, and no tnsnames.ora entry is required.

Connectionless Session with /NOLOG

In the command-line interface, it is possible to start SQL*Plus without connecting to a database. This is useful for performing some database administration tasks, writing transportable scripts, or to use SQL*Plus editing commands to write or edit scripts.

You use the /NOLOG argument to the SQLPLUS command to start a connectionless command-line session. After SQL*Plus has started you can connect to a database with the CONNECT command.

Example 4-6 Start a connectionless SQL*Plus session with /NOLOG

SQLPLUS /NOLOG 

Starting SQL*Plus

If you are connecting to a remote Oracle database, make sure your Oracle Net software is installed and working properly. For more information, see the Oracle Net Services Administrator's Guide.

When you start a SQL*Plus command-line or Windows GUI session, and after a CONNECT command in that session, the site profile, glogin.sql, and the user profile file, login.sql, are processed:

The site profile file, glogin.sql is processed first, then the user profile file, login.sql.

When you start an iSQL*Plus session, and after a CONNECT command in that session, the site profile, glogin.sql, is processed:

Behavior in SQL*Plus 10.1 may be unexpected depending on the setting of SET SQLPLUSCOMPATIBILITY. For example, processing glogin.sql and login.sql after a CONNECT command only occurs with the default SQLPLUSCOMPATIBILITY setting of 10.1. For more information, see SET SQLPLUSCOMPAT[IBILITY] {x.y[.z]}.

Starting Command-line SQL*Plus

To begin using SQL*Plus, you must first understand how to start and stop SQL*Plus.

Example 4-7 Starting SQL*Plus

This example shows you how to start SQL*Plus:

  1. Make sure that SQL*Plus has been installed on your computer.

  2. Log on to the operating system (if required).

  3. Enter the command, SQLPLUS, and press Return.


    Note:

    Some operating systems expect you to enter commands in lowercase letters. If your system expects lowercase, enter the SQLPLUS command in lowercase.

    SQLPLUS
    

    SQL*Plus displays its version number, the current date, and copyright information, and prompts you for your username (the text displayed on your system may differ slightly):

    SQL*Plus: Release 10.1.0.2.0 - Production on Thu Oct 5 16:29:01 2003
    (c) Copyright 1982, 2003 Oracle Corporation. All rights reserved.
    Enter user-name:
    

  4. Enter your username and press Return. SQL*Plus displays the prompt "Enter password:".

  5. Enter your password and press Return again. For your protection, your password does not appear on the screen.

    The process of entering your username and password is called logging in. SQL*Plus displays the version of Oracle Database to which you connected and the versions of available tools such as PL/SQL.

    Next, SQL*Plus displays the SQL*Plus command prompt:

    SQL>
    

    The SQL*Plus command prompt indicates that SQL*Plus is ready to accept your commands.

If SQL*Plus does not start, you should see a message to help you correct the problem.

Shortcuts to Starting Command-line SQL*Plus

When you start SQL*Plus, you can enter your username and password, separated by a slash (/), following the command SQLPLUS. For example, you can enter

SQLPLUS HR/your_password

and press Return.

Getting Command-line Help

To access command-line help for SQL*Plus commands, type HELP or ? followed by the command name at the SQL command prompt or in the iSQL*Plus Workspace Input area. See the HELP command for more information. For example:

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 fits in a standard screen. For example:

HELP INDEX

Starting the Windows Graphical User Interface

The graphical user interface can be started from the Windows menu, or from a Windows command prompt.

Starting the GUI from the Windows Menu

  1. Select Programs in the Start menu. Then select Oracle - ORACLE_HOME, then Application Development, and click SQL Plus.

    The SQL*Plus window appears displaying the Log On dialog.

    Description of logon.gif follows
    Description of the illustration logon.gif

    Enter a valid user name and password. If you are connecting to a remote Oracle database, enter the Oracle Net connect identifier in the Host String field. To connect to the default database, leave the Host String field blank. See Easy Connection Identifier earlier for more information about configuring and using Oracle Net connect identifiers.

  2. Click OK.

Starting the GUI from the Windows Command Prompt

  1. Select Command Prompt from Programs->Accessories in the Start menu. A Command Prompt window appears.

  2. Enter

    C:\> SQLPLUSW
    

    The SQL*Plus graphical user interface starts. You can optionally include your login username and password separated by a slash (/), and a database to connect to, for example:

    C:\> SQLPLUSW username/password@connect_identifier
    

    Otherwise enter the required information in the login dialog as described in Starting SQL*Plus earlier. The Oracle SQL*Plus application window appears.

Description of wingui.gif follows
Description of the illustration wingui.gif

Starting the iSQL*Plus Application Server

The iSQL*Plus Application Server must be running on the middle tier before you can start an iSQL*Plus session. A command-line utility and a Windows Service are supplied to start and stop iSQL*Plus on Windows.

The iSQL*Plus Application Server is started by default during Oracle Database installation.


To Start the iSQL*Plus Application Server on Unix
  1. Start a terminal session.

  2. Enter

    $ORACLE_HOME/bin/isqlplusctl start
    

    The iSQL*Plus Application Server is started.


To Start the iSQL*Plus Application Server on Windows
  1. Select Services from the Start > Programs > Administrative Tools menu.

  2. Locate the iSQL*Plus Windows Service, OracleOracleHomeNameiSQL*Plus.

  3. Start the Windows Service.

Alternatively, you can start iSQL*Plus from a command prompt.


To Start iSQL*Plus Application Server from a Command Prompt
  1. Start a command prompt session.

  2. Enter

    %ORACLE_HOME%\bin\isqlplusctl start
    

    The iSQL*Plus Application Server is started.


To Test If the iSQL*Plus Application Server Has Started Correctly
  1. Enter the iSQL*Plus URL in your web browser. The iSQL*Plus URL is in the form:

    http://machine_name:5560/isqlplus/
    

    iSQL*Plus uses HTTP port 5560 by default. If iSQL*Plus is not available on port 5560, read the $ORACLE_HOME/install/portlist.ini file to find the port on which iSQL*Plus is running.

  2. Enter one of the following URLs from a web browser on the machine running the iSQL*Plus Application Server if you do not know the iSQL*Plus URL:

    http://127.0.0.1:5560/isqlplus/
    http://localhost:5560/isqlplus/
    

    The iSQL*Plus Login screen should be displayed.

  3. Enter the same URL you used in step 2, without "isqlplus/" if the iSQL*Plus Login screen was not displayed in step 2. This is to establish whether the OC4J instance has started correctly:

    http://127.0.0.1:5560/
    http://localhost:5560/
    

    The OC4J default page should be displayed.

    If the OC4J default page is not displayed, the iSQL*Plus Application Server is not running. Also see Testing if the iSQL*Plus Application Server is Running.

To Check the HTTP Port used by the iSQL*Plus Application Server

To discover the HTTP port number used by the iSQL*Plus Application Server, search the $ORACLE_HOME/install/portlist.ini file on the Application Server. Also see Changing the iSQL*Plus Application Server Port in Use.

Stopping the iSQL*Plus Application Server


To Stop the iSQL*Plus Application Server on Unix
  1. Start a command line session.

  2. Enter

    $ORACLE_HOME/bin/isqlplusctl stop
    

    The iSQL*Plus Application Server is stopped.


To Stop the iSQL*Plus Application Server on Windows
  1. Select Services from the Start > Settings > Administration Tools menu.

  2. Locate the iSQL*Plus Windows Service, OracleOracleHomeNameiSQL*Plus.

  3. Stop the Windows Service.


To Stop the iSQL*Plus Application Server from the Command Prompt
  1. Start a command line session.

  2. Enter

    %ORACLE_HOME%\bin\isqlplusctl stop
    

    The iSQL*Plus Application Server is stopped.

Once stopped, no iSQL*Plus sessions are possible through this server until the iSQL*Plus Application Server is restarted.

Running iSQL*Plus

To start an iSQL*Plus session

  1. Enter the Uniform Resource Locator (URL) of iSQL*Plus in the Location field of your web browser, for example:

    http://machine_name.domain:port/isqlplus
    

    where machine_name.domain is the URL, and port is the port number for the Application Server you want to use. The iSQL*Plus Login screen is displayed.

    Each successful login is uniquely identified, so you can have multiple iSQL*Plus sessions running from the same machine, or from multiple client machines.

  2. Enter your Username, Password and Connection Identifier. See Login Username and Password and "Connecting to a Database" for more information.

  3. Click the Login button. The iSQL*Plus Workspace is displayed.

Running iSQL*Plus as a DBA

To start an iSQL*Plus session with SYSDBA or SYSOPER privileges, you use the iSQL*Plus DBA URL which has the form:

http://machine_name:port/isqlplus/dba/

To access the iSQL*Plus DBA URL, you must set up login credentials using the Oracle JAAS Provider, known as JAZN (Java AuthoriZatioN). See Enabling iSQL*Plus DBA Access for information on accessing the iSQL*Plus DBA URL.

When you are connected through the iSQL*Plus DBA URL, the Application Server authentication enables AS SYSDBA or AS SYSOPER connections through the DBA Login screen, or through a CONNECT command, but the Oracle Database username and password authentication may still prevent access.

Starting iSQL*Plus from a URL

You can start iSQL*Plus and pass URL variables, SQL scripts and substitution variables by sending a request from a URL.

SQL scripts must be available through HTTP or FTP, or passed to iSQL*Plus as a URL variable. iSQL*Plus executes the script and returns the results in a web browser window, or loads the script into the Workspace.

You can start iSQL*Plus as a normal user, or with SYSDBA or SYSOPER privileges.

The syntax to enter in your web browser's Location/Address field to start iSQL*Plus as a normal user is:

http://machine_name.domain:port/isqlplus[/dynamic?UserOpts]

or to start iSQL*Plus with SYSDBA or SYSOPER privileges, use:

http://machine_name.domain:port/isqlplus/dba[/dynamic?DBAOpts]

where

machine_name.domain is the URL of the Application Server

port is the number of the port used by the Application Server

UserOpts is UserLogin|Script|UserLogin&Script

DBAOpts is DBALogin|Script|DBALogin&Script

and

UserLogin is userid=username[/password][@connect_identifier]

DBALogin is userid={username[/password][@connect_identifier]
| / } AS {SYSDBA | SYSOPER}

Script is script=text[&type={url|text}][&action={execute|load}][&variable=value ...]

If there is no userid URL parameter or if it has incomplete information, iSQL*Plus displays the login screen. If the URL parameter is complete and the login information is valid, iSQL*Plus connects and continues with the request.

SQL script parameters can be given in any order. If any user variable script parameter begins with a reserved keyword, such as script or userid, iSQL*Plus may interpret it as a command rather than as a literal parameter.

If the URL parameter type is url, or if it is not specified, the script parameter is assumed to be the URL of a SQL script.

If the URL parameter type is text, the text in the script parameter is assumed to be the contents of the SQL script itself. There may be HTML character set restrictions on scripts passed using this method.

If the URL parameter action is execute, or if it is not specified, the SQL script is executed in iSQL*Plus.

If the URL parameter action is load, the script is loaded into the Workspace, but it is not executed. A web browser may not be able to display large scripts in the Workspace, and as a result, scripts may be truncated.

Examples

To log into iSQL*Plus with the username HR and password your_password, enter

http://machine_name.domain:5560/isqlplus/dynamic?userid=HR/your_password

To execute a script that is located at the URL http://machine_name2.domain/myscript.sql in iSQL*Plus, and prompt for username and password, enter

http://machine_name.domain:5560/isqlplus/dynamic?script=http://machine_name2.domain/myscript.sql

To execute a script that is located at a URL, pass the username and password, login to a database, and pass parameters to the script to provide values for substitution variables, enter

http://machine_name.domain:5560/isqlplus/dba/dynamic?userid=hr/your_password@oracle10g%20as%20sysdba&script=ftp://machine_name2.domain/script.sql&name=*&salary=12000

As the iSQL*Plus DBA URL is used, Application Server authentication is also required. As spaces are not supported, they have been encoded as %20 in this example.

To load a script into iSQL*Plus without passing the username and password, enter

http://machine_name.domain:5560/isqlplus/dynamic?script=select%20*%20from%20emp_details_view;&type=text&action=load

Getting Help in iSQL*Plus

To access iSQL*Plus Online Help, click the Help icon. Help specific to iSQL*Plus is displayed in a new browser window. It is available in eight languages:

Brazilian Portuguese
French
German
Italian
Japanese
Korean
Simplified Chinese
Spanish

English is installed by default, and where a language is unavailable.

For more information about language support in SQL*Plus, see Chapter 12, "SQL*Plus Globalization Support".

Exiting SQL*Plus

The way you exit SQL*Plus from each of the three user interfaces is described in the following sections.

If you fail to log in to SQL*Plus successfully 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 for further information.

Exiting the Command-line User Interface

When you are done working with SQL*Plus and wish to return to the operating system, enter EXIT or QUIT at the SQL*Plus prompt, or enter the end of file character, Ctrl+D on UNIX or Ctrl+Z on Windows.

SQL*Plus displays the version of Oracle Database from which you disconnected and the versions of tools available through SQL*Plus. After a moment you will see the operating system prompt.

Exiting the Windows Graphical User Interface

You can exit the Windows GUI in exactly the same way as you exit the command-line user interface, by entering EXIT or QUIT at the SQL*Plus prompt.

You can also click Exit from the File menu to exit the Windows GUI and return to Windows.

Exiting the iSQL*Plus User Interface

To exit iSQL*Plus, click the Logout icon.

It is recommended that you always use the Logout icon to exit iSQL*Plus to free up system and server resources.

In iSQL*Plus, the EXIT or QUIT command halts the script currently running, it does not terminate your session.

SQLPLUS Program Syntax

You use the SQLPLUS command at the operating system prompt to start command-line SQL*Plus:

SQLPLUS [ [Options] [Logon] [Start] ]

where: Options has the following syntax:

-H[ELP]|-V[ERSION]
 |[[-C[OMPATIBILITY] {x.y[.z]] [-L[OGON]] [-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}]

where Logon has the following syntax:

{username[/password][@connect_identifier] | / } [AS {SYSOPER|SYSDBA}] 
  |/NOLOG 

where Start has the following syntax:

@{url|file_name[.ext]} [arg ...]

You have the option of entering logon. If you do not specify logon but do specify start, SQL*Plus assumes that the first line of the script contains a valid logon. If neither start nor logon are specified, SQL*Plus prompts for logon information.

Options

The following sections contain descriptions of SQLPLUS command options:

COMPATIBILITY Option

-C[OMPATIBILITY] {x.y[.z]

Sets the value of the SQLPLUSCOMPATIBILITY system variable to the SQL*Plus release specified by x.y[.z]. Where x is the version number, y is the release number, and z is the update number. For example, 9.0.1 or 10.1. For more information, see the SET SQLPLUSCOMPAT[IBILITY] {x.y[.z]}system variable.

HELP Option

-H[ELP]

Displays the usage and syntax for the SQLPLUS command, and then returns control to the operating system.

VERSION Option

-V[ERSION]

Displays the current version and level number for SQL*Plus, and then returns control to the operating system.

LOGON Option

-L[OGON]

Specifies not to reprompt for username or password if the initial connection does not succeed. This can be useful in operating system scripts that must either succeed or fail and you don't want to be reprompted for connection details if the database server is not running. The -LOGON option is not supported in the Windows GUI.

MARKUP Options

-M[ARKUP]

You can use the MARKUP option to generate a complete stand alone web page from your query or script. MARKUP currently supports HTML 4.0 transitional.


Note:

Depending on your operating system, the complete markup_option clause for the SQLPLUS command may need to be contained in quotes.

Use SQLPLUS -MARKUP HTML ON or SQLPLUS -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 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 the default behavior when the HTML option is set ON. You can generate output using HTML <PRE> tags by setting PREFORMAT ON.

In SQL*Plus, 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 other information on the SET MARKUP command, see the SET command.

HTML [ON|OFF]

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.

You can turn HTML output ON and OFF as required during a session. The default is OFF.

HEAD text

The HEAD text option enables you to specify content for the <HEAD> tag. By default, text includes a default in-line cascading style sheet and 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.

BODY text

The BODY text option enables 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.

TABLE text

The TABLE text option enables 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|OFF}

ENTMAP ON or OFF specifies whether or not SQL*Plus replaces special characters <, >, " and & with the HTML entities &lt;, &gt;, &quot; and &amp; 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>PROMPT A > BA > B

With ENTMAP ON, SQL*Plus screen output is:

SQL&gt; PROMPT A > B
A &gt; B

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.

If entities are not mapped, web browsers may treat data as invalid HTML and all subsequent output may display incorrectly. ENTMAP OFF enables users to write their own HTML tags to customize output.


Note:

ENTMAP only takes effect when the HTML option is set ON. For more information about using entities in your output, see the COLUMN command.

SPOOL {ON|OFF}

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.


Note:

It is important to distinguish between the SET MARKUP HTML SPOOL option, and the SQLPLUS SPOOL filename command.

The SET MARKUP HTML SPOOL ON option enables the writing of the <HTML> tag to the spool file. The spool file is not created, and the header and footer tags enabled by the SET MARKUP HTML SPOOL ON option are not written to the spool file until you issue the SQLPLUS SPOOL filename command. See SPOOL command in Chapter 13, "SQL*Plus Command Reference" for more information.


SQL*Plus writes several HTML tags to the spool file when you issue the SPOOL filename command.

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

PRE[FORMAT] {ON|OFF}

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"

or

SET MARKUP HTML ON PREFORMAT ON


MARKUP Usage Notes

When MARKUP HTML ON PREFORMAT OFF is used, commands originally intended to format paper reports have different meaning for reports intended for web tables:

  • PAGESIZE is the number of rows in an HTML table, not the number of lines. Each row may contain multiple lines. The TTITLE, BTITLE and column headings are repeated every PAGESIZE rows.

  • LINESIZE may have an effect on data if wrapping is on, or for very long data. Depending on data size, output may be generated on separate lines, which a browser may interpret as a space character.

  • TTITLE and BTITLE content is output to three line positions: left, center and right, and the maximum line width is preset to 90% of the browser window. These elements may not align with the main output as expected due to the way they are handled for web output. Entity mapping in TTITLE and BTITLE is the same as the general ENTMAP setting specified in the MARKUP command.

  • If you use a title in your output, then SQL*Plus starts a new HTML table for output rows that appear after the title. Your browser may format column widths of each table differently, depending on the width of data in each column.

  • SET COLSEP, RECSEP and UNDERLINE only produce output in HTML reports when PREFORMAT is ON.

RESTRICT Option

-R[ESTRICT] {1|2|3}

Enables 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 4-1 Commands Disabled by Restriction Level

Command Level 1 Level 2 Level 3
EDIT disabled disabled disabled
GET

disabled
HOST disabled disabled disabled
SAVE
disabled disabled
SPOOL
disabled disabled
START, @, @@

disabled
STORE
disabled disabled

SILENT Option

-S[ILENT]

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 script. The SQL*Plus banner and prompts are suppressed and do not appear in reports created using the SILENT option.

Logon

username[/password]

Represent the username and password with which you wish to start SQL*Plus and connect to Oracle Database. If you enter your password on the command-line as part of the SQLPLUS command in the form,

sqlplus username[/password]

it may be viewable by anyone on your system. Some operating systems have monitoring tools that list all executing commands and their arguments.

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 when you type it, but not your password.

@connect_identifier

Consists of an Oracle Net connect identifier. The exact syntax depends upon the Oracle Net communications protocol your Oracle Database installation uses. For more information, refer to the Oracle Net manual appropriate for your protocol or contact your DBA.

/

Represents a default logon using operating system authentication. You cannot enter a connect identifier 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 Oracle Database Administrator's Guide for information about operating system authentication.

AS {SYSOPER|SYSDBA}

The AS clause enables privileged connections by users who have been granted SYSOPER or SYSDBA system privileges.

/NOLOG

Establishes no initial connection to Oracle Database. 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 script prompt for the username, password, or database specification. The first line of this script is not assumed to contain a logon.

Start

@{url|file_name[.ext]} [arg ...]

Specifies the name of a script and arguments to run. The script can be called from the local file system or from a web server.

SQL*Plus passes the arguments to the script as if executing the file using the SQL*Plus START command. If no file suffix (file extension) is specified, the suffix defined by the SET SUFFIX command is used. The default suffix is .sql.

See the START command for more information.