Skip Headers

SQL*Plus User's Guide and Reference
Release 9.2

Part Number A90842-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback

Go to previous page Go to next page

13
SQL*Plus Command Reference

This chapter contains descriptions of the SQL*Plus commands available in command-line and iSQL*Plus interfaces listed alphabetically. Each description contains the following parts:

Syntax

Shows how to enter the command and provides a brief description of the basic uses of the command. Refer to "Conventions in Code Examples" for an explanation of the syntax notation

Terms

Describes the function of each term or clause appearing in the syntax.

Usage

Provides additional information on uses of the command and on how the command works.

Examples

Gives one or more examples of the command.

A summary table that lists and briefly describes SQL*Plus commands precedes the individual command descriptions.

You can continue a long SQL*Plus command by typing a hyphen at the end of the line and pressing [Return]. If you wish, you can type a space before typing the hyphen. SQL*Plus displays a right angle-bracket (>) as a prompt for each additional line.

You do not need to end a SQL*Plus command with a semicolon. When you finish entering the command, you can just press [Return]. If you wish, however, you can enter a semicolon at the end of a SQL*Plus command.

SQL*Plus Command Summary

Command Description

@ ("at" sign)

Runs the SQL*PLus statements in the specified script. The script can be called from the local file system or from a web server.

@@ (double "at" sign)

Runs a script. This command is similar to the @ ("at" sign) command. It is useful for running nested scripts because it looks for the specified script in the same path as the script from which it was called.

/ (slash)

Executes the SQL command or PL/SQL block.

ACCEPT

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

APPEND

Adds specified text to the end of the current line in the buffer.

ARCHIVE LOG

Starts or stops the automatic archiving of online redo log files, manually (explicitly) archives specified redo log files, or displays information about redo log files.

ATTRIBUTE

Specifies display characteristics for a given attribute of an Object Type column, and lists the current display characteristics for a single attribute or all attributes.

BREAK

Specifies where and how formatting will change in a report, or lists the current break definition.

BTITLE

Places and formats a specified title at the bottom of each report page, or lists the current BTITLE definition.

CHANGE

Changes text on the current line in the buffer.

CLEAR

Resets or erases the current clause or setting for the specified option, such as BREAKS or COLUMNS.

COLUMN

Specifies display characteristics for a given column, or lists the current display characteristics for a single column or for all columns.

COMPUTE

Calculates and prints summary lines, using various standard computations, on subsets of selected rows, or lists all COMPUTE definitions.

CONNECT

Connects a given user to Oracle.

COPY

Copies results from a query to a table in a local or remote database.

DEFINE

Specifies a user variable and assigns it a CHAR value, or lists the value and variable type of a single variable or all variables.

DEL

Deletes one or more lines of the buffer.

DESCRIBE

Lists the column definitions for the specified table, view, or synonym or the specifications for the specified function or procedure.

DISCONNECT

Commits pending changes to the database and logs the current user off Oracle, but does not exit SQL*Plus.

EDIT

Invokes a host operating system text editor on the contents of the specified file or on the contents of the buffer.

EXECUTE

Executes a single PL/SQL statement.

EXIT

Terminates SQL*Plus and returns control to the operating system.

GET

Loads a host operating system file into the SQL buffer.

HELP

Accesses the SQL*Plus help system.

HOST

Executes a host operating system command without leaving SQL*Plus.

INPUT

Adds one or more new lines after the current line in the buffer.

LIST

Lists one or more lines of the SQL buffer.

PASSWORD

Allows a password to be changed without echoing the password on an input device.

PAUSE

Displays the specified text, then waits for the user to press [Return].

PRINT

Displays the current value of a bind variable.

PROMPT

Sends the specified message to the user's screen.

QUIT

Terminates SQL*Plus and returns control to the operating system. QUIT is identical to EXIT.

RECOVER

Performs media recovery on one or more tablespaces, one or more datafiles, or the entire database.

REMARK

Begins a comment in a script.

REPFOOTER

Places and formats a specified report footer at the bottom of each report, or lists the current REPFOOTER definition.

REPHEADER

Places and formats a specified report header at the top of each report, or lists the current REPHEADER definition.

RUN

Lists and executes the SQL command or PL/SQL block currently stored in the SQL buffer.

SAVE

Saves the contents of the SQL buffer in a host operating system file (a script).

SET

Sets a system variable to alter the SQL*Plus environment for your current session.

SHOW

Shows the value of a SQL*Plus system variable or the current SQL*Plus environment.

SHUTDOWN

Shuts down a currently running Oracle instance.

SPOOL

Stores query results in an operating system file and, optionally, sends the file to a printer.

START

Executes the contents of the specified script. The script can only be called from a url.

STARTUP

Starts an Oracle instance and optionally mounts and opens a database.

STORE

Saves attributes of the current SQL*Plus environment in a host operating system file (a script).

TIMING

Records timing data for an elapsed period of time, lists the current timer's title and timing data, or lists the number of active timers.

TTITLE

Places and formats a specified title at the top of each report page, or lists the current TTITLE definition.

UNDEFINE

Deletes one or more user variables that you defined either explicitly (with the DEFINE command) or implicitly (with an argument to the START command).

VARIABLE

Declares a bind variable that can be referenced in PL/SQL.

WHENEVER OSERROR

Performs the specified action Exits SQL*Plus if an operating system command generates an error.

WHENEVER SQLERROR

Performs the specified action Exits SQL*Plus if a SQL command or PL/SQL block generates an error.

@ ("at" sign)

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

Runs the SQL*Plus statements in the specified script. The script can be called from the local file system or from a web server. Only the url form is supported in iSQL*Plus.

Terms

Refer to the following for a description of the term or clause:

url

Specifies the Uniform Resource Locator of a script to run on the specified web server. SQL*Plus supports HTTP and FTP protocols.

file_name[.ext]

Represents the script you wish to run. If you omit ext, SQL*Plus assumes the default command-file extension (normally SQL). For information on changing the default extension, see the SUFFIX variable of the SET command.

When you enter @file_name.ext, SQL*Plus searches for a file with the filename and extension you specify in the current default directory. If SQL*Plus does not find such a file, SQL*Plus will search a system-dependent path to find the file. Some operating systems may not support the path search. See the Oracle installation and user's manual(s) provided for your operating system for specific information related to your operating system environment.

arg...

Represent data items you wish to pass to parameters in the script. If you enter one or more arguments, SQL*Plus substitutes the values into the parameters (&1, &2, and so forth) in the script. The first argument replaces each occurrence of &1, the second replaces each occurrence of &2, and so forth.

The @ command DEFINEs the parameters with the values of the arguments; if you run the script again in this session, you can enter new arguments or omit the arguments to use the current values.

For more information on using parameters, refer to the subsection "Substitution Variables in iSQL*Plus" under "Writing Interactive Commands".

Usage

All previous settings like COLUMN command settings stay in effect when the script starts. If the script changes any setting, then this new value stays in effect after the script has finished

In a script, you can include any command you would normally enter interactively (typically, SQL, SQL*Plus commands, or PL/SQL blocks).

An EXIT or QUIT command used in a script terminates SQL*Plus.

The @ command functions similarly to START.

If the START command is disabled (see "Disabling SQL*Plus, SQL, and PL/SQL Commands"), this will also disable the @ command. See START for information on the START command.

SQL*Plus removes the SQLTERMINATOR (a semicolon by default) before the @ command is issued. If you require a semicolon in your command, add a second SQLTERMINATOR. See the SQLTERMINATOR variable of the SET command in this chapter for more information.

Examples

To run a script named PRINTRPT with the extension SQL, enter

Keyboard icon
@PRINTRPT

To run a script named WKRPT with the extension QRY, enter

Keyboard icon
@WKRPT.QRY

You can run a script named YEAREND specified by a URL, and pass values to variables referenced in YEAREND in the usual way:

Keyboard icon
@HTTP://machine_name.domain:port/YEAREND.SQL VAL1 VAL2 @FTP://machine_name.domain:port/YEAREND.SQL VAL1 VAL2

On a web server configured to serve SQL reports, you could request SQL*Plus to execute a dynamic script by using:

Keyboard icon
@HTTP://machine_name.domain:port/SCRIPTSERVER?ENDOFYEAR VAL1 VAL2

@@ (double "at" sign)

@@url|file_name[.ext]

Runs a script. This command is almost identical to the @ ("at" sign) command. It is useful for running nested scripts because it has the additional functionality of looking for the specified script in the same path or url as the script from which it was called. Only the url form is supported in iSQL*Plus.

Terms

Refer to the following for a description of the term or clause:

url

Specifies the Uniform Resource Locator of a script to run on the specified web server. SQL*Plus supports HTTP and FTP protocols.

file_name[.ext]

Represents the nested script you wish to run. If you omit ext, SQL*Plus assumes the default command-file extension (normally SQL). For information on changing the default extension, see the SUFFIX variable of the SET command.

When you enter @@file_name.ext from within a script, SQL*Plus runs file_name.ext from the same directory as the script.

When you enter @@file_name.ext interactively, SQL*Plus runs file_name.ext from the current working directory or from the same url as the script from which it was called. If SQL*Plus does not find such a file, SQL*Plus searches a system-dependent path to find the file. Some operating systems may not support the path search. See the Oracle installation and user's manual provided for your operating system for specific information related to your operating system environment.

Usage

All previous settings like COLUMN command settings stay in effect when the script starts. If the script changes any setting, then this new value stays in effect after the script has finished

You can include in a script any command you would normally enter interactively (typically, SQL or SQL*Plus commands).

An EXIT or QUIT command used in a script terminates SQL*Plus.

The @@ command functions similarly to START.

If the START command is disabled (see "Disabling SQL*Plus, SQL, and PL/SQL Commands"), this will also disable the @@ command. For more information, see the SPOOL command.

SQL*Plus removes the SQLTERMINATOR (a semicolon by default) before the @@ command is issued. A workaround for this is to add another SQLTERMINATOR. See the SQLTERMINATOR variable of the SET command for more information.

Examples

Suppose that you have the following script named PRINTRPT:

Keyboard icon
SELECT DEPARTMENT_ID, CITY FROM EMP_DETAILS_VIEW WHERE SALARY>12000; @EMPRPT.SQL @@ WKRPT.SQL

When you START PRINTRPT and it reaches the @ command, it looks for the script named EMPRPT in the current working directory and runs it. When PRINTRPT reaches the @@ command, it looks for the script named WKRPT in the same path as PRINTRPT and runs it.

Suppose that the same script PRINTRPT was located on a web server and you ran it with START HTTP://machine_name.domain:port/PRINTRPT. When it reaches the @ command, it looks for the script named EMPRPT in the current local working directory and runs it. When PRINTRPT reaches the @@ command, it looks for the script named WKRPT in the same url as PRINTRPT, HTTP://machine_name.domain:port/WKRPT.SQL and runs it.

/ (slash)

/(slash)

Executes the SQL command or PL/SQL block currently stored in the SQL buffer.

Usage

You can enter a slash (/) at the command prompt or at a line number prompt of a multi-line command.

The slash command functions similarly to RUN, but does not list the command in the buffer on your screen.

Executing a SQL command or PL/SQL block using the slash command will not cause the current line number in the SQL buffer to change unless the command in the buffer contains an error. In that case, SQL*Plus changes the current line number to the number of the line containing the error.

Examples

Type the following SQL script:

Keyboard icon
SELECT CITY, COUNTRY_NAME FROM EMP_DETAILS_VIEW WHERE SALARY=12000;

Enter a slash (/) at the command prompt to re-execute the command in the buffer:

Keyboard icon
/ Screen icon
CITY COUNTRY_NAME ------------------------------ ---------------------------------------- Seattle United States of America Oxford United Kingdom Seattle United States of America

ACCEPT

ACCEPT is not available in iSQL*Plus.

ACC[EPT] variable [NUM[BER]|CHAR|DATE] [FOR[MAT] format] [DEF[AULT] default]
[PROMPT text|NOPR[OMPT]] [HIDE]

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

Terms

Refer to the following list for a description of each term or clause:

variable

Represents the name of the variable in which you wish to store a value. If variable does not exist, SQL*Plus creates it.

NUM[BER]

Makes the datatype of variable the datatype NUMBER. If the reply does not match the datatype, ACCEPT gives an error message and prompts again.

CHAR

Makes the datatype of variable the datatype CHAR. The maximum CHAR length limit is 240 bytes. If a multi-byte character set is used, one CHAR may be more than one byte in size.

DATE

Makes reply a valid DATE format. If the reply is not a valid DATE format, ACCEPT gives an error message and prompts again. The datatype is CHAR.

FOR[MAT]

Specifies the input format for the reply. If the reply does not match the specified format, ACCEPT gives an error message and prompts again for a reply. The format element must be a text constant such as A10 or 9.999. See the CHANGE command in this chapter for a complete list of format elements.

Oracle date formats such as "dd/mm/yy" are valid when the datatype is DATE. DATE without a specified format defaults to the Oracle NLS_DATE_FORMAT of the current session. See the Oracle9i Database Administrator's Guide and the Oracle9i SQL Reference for information on Oracle date formats.

DEF[AULT]

Sets the default value if a reply is not given. The reply must be in the specified format if defined.

PROMPT text

Displays text on-screen before accepting the value of variable from the user.

NOPR[OMPT]

Skips a line and waits for input without displaying a prompt.

HIDE

Suppresses the display as you type the reply.

To display or reference variables, use the DEFINE command. See the DEFINE command in this chapter for more information.

Examples

To display the prompt "Password: ", place the reply in a CHAR variable named PSWD, and suppress the display, enter

Keyboard icon
ACCEPT pswd CHAR PROMPT 'Password: ' HIDE

To display the prompt "Enter weekly salary: " and place the reply in a NUMBER variable named SALARY with a default of 000.0, enter

Keyboard icon
ACCEPT salary NUMBER FORMAT '999.99' DEFAULT '000.0' - PROMPT 'Enter weekly salary: '

To display the prompt "Enter date hired: " and place the reply in a DATE variable named HIRED with the format "dd/mm/yyyy" and a default of "01/01/2001", enter

Keyboard icon
ACCEPT hired DATE FORMAT 'dd/mm/yyyy' DEFAULT '01/01/2001'- PROMPT 'Enter date hired: '

APPEND

APPEND is not available in iSQL*Plus.

A[PPEND] text

Adds specified text to the end of the current line in the SQL buffer.

Terms

Refer to the following for a description of the term or clause:

text

Represents the text to append. To separate text from the preceding characters with a space, enter two spaces between APPEND and text.

To APPEND text that ends with a semicolon, end the command with two semicolons (SQL*Plus interprets a single semicolon as an optional command terminator).

Examples

To append a comma delimiter, a space and the column name CITY to the first line of the buffer, make that line the current line by listing the line as follows:

Keyboard icon
1 Screen icon
1* SELECT DEPARTMENT_ID

Now enter APPEND:

Keyboard icon
APPEND , CITY 1 Screen icon
1* SELECT DEPARTMENT_ID, CITY

To append a semicolon to the line, enter

Keyboard icon
APPEND ;;

SQL*Plus appends the first semicolon to the line and interprets the second as the terminator for the APPEND command.

ARCHIVE LOG

ARCHIVE LOG {LIST|STOP}|{START|NEXT|ALL|integer } [TO destination]

Starts or stops automatic archiving of online redo log files, manually (explicitly) archives specified redo log files, or displays information about redo log files.

Terms

Refer to the following list for a description of each term or clause:

LIST

Requests a display that shows the range of redo log files to be archived, the current log file group's sequence number, and the current archive destination (specified by either the optional command text or by the initialization parameter LOG_ARCHIVE_DEST).

If you are using both ARCHIVELOG mode and automatic archiving, the display might appear like:

ARCHIVE LOG LIST

Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /vobs/oracle/dbs/arch
Oldest online log sequence     221
Next log sequence to archive   222
Current log sequence           222

Since the log sequence number of the current log group and the next log group to archive are the same, automatic archival has archived all log groups up to the current one.

If you are using ARCHIVELOG but have disabled automatic archiving, the last three lines might look like:

Oldest online log sequence            222
Next log sequence to archive          222
Current log sequence                  225

If you are using NOARCHIVELOG mode, the "next log sequence to archive" line is suppressed.

The log sequence increments every time the Log Writer begins to write to another redo log file group; it does not indicate the number of logs being used. Every time an online redo log file group is reused, the contents are assigned a new log sequence number.

STOP

Disables automatic archival. If the instance is still in ARCHIVELOG mode and all redo log file groups fill, database operation is suspended until a redo log file is archived (for example, until you enter the command ARCHIVE LOG NEXT or ARCHIVE LOG ALL).

START

Enables automatic archiving. Starts the background process ARCH, which performs automatic archiving as required. If ARCH is started and a filename is supplied, the filename becomes the new default archive destination. ARCH automatically starts on instance startup if the initialization parameter LOG_ARCHIVE_START is set to TRUE.

NEXT

Manually archives the next online redo log file group that has been filled, but not yet archived.

ALL

Manually archives all filled, but not yet archived, online redo log file groups.

integer

Causes archival of the online redo log file group with log sequence number n. You can specify any redo log file group that is still online. An error occurs if the log file cannot be found online or the sequence number is not valid. This option can be used to re-archive a log file group.

destination

Specifies the destination device or directory in an operating system. Specification of archive destination devices is installation-specific; see your platform-specific Oracle documentation for examples of specifying archive destinations. On many operating systems, multiple log files can be spooled to the same tape.

If not specified in the command-line, the archive destination is derived from the initialization parameter LOG_ARCHIVE_DEST. The command ARCHIVE LOG START destination causes the specified device or directory to become the new default archive destination for all future automatic or manual archives. A destination specified with any other option is a temporary destination that is in effect only for the current (manual) archive. It does not change the default archive destination for subsequent automatic archives. For information about specifying archive destinations, see your platform-specific Oracle documentation.

Usage

You must be connected to an open Oracle database as SYSOPER, or SYSDBA. For information about connecting to the database, see the CONNECT command in this chapter.

If an online redo log file group fills and none are available for reuse, database operation is suspended. The condition can be resolved by archiving a log file group.

For information about specifying archive destinations, see your platform-specific Oracle documentation.


Note::

This command applies only to the current instance. To specify archiving for a different instance or for all instances in a Parallel Server, use the SQL command ALTER SYSTEM. For more information about using SQL commands, see the Oracle9i SQL Reference.


Examples

To start up the archiver process and begin automatic archiving, using the archive destination specified in LOG_ARCHIVE_DEST, enter

Keyboard icon
ARCHIVE LOG START

To stop automatic archiving, enter

Keyboard icon
ARCHIVE LOG STOP

To archive the log file group with sequence number 1001 to the destination specified, enter

Keyboard icon
ARCHIVE LOG 1001 '/vobs/oracle/dbs/arch'

'arch' specifies the prefix of the filename on the destination device; the remainder of the filename is dependent on the initialization parameter LOG_ARCHIVE_FORMAT, which specifies the filename format for archived redo log files.

ATTRIBUTE

ATTRIBUTE [type_name.attribute_name [option ...]]

where option represents one of the following clauses:

ALI[AS] alias
CLE[AR]
FOR[MAT] format
LIKE {type_name.attribute_name|alias}
ON|OFF

Specifies display characteristics for a given attribute of an Object Type column, such as format for NUMBER data.

Also lists the current display characteristics for a single attribute or all attributes.

Terms

Enter ATTRIBUTE followed by type_name.attribute_name and no other clauses to list the current display characteristics for only the specified attribute. Enter ATTRIBUTE with no clauses to list all current attribute display characteristics.

Refer to the following list for a description of each term or clause:

type_name.attribute_name

Identifies the data item (typically the name of an attribute) within the set of attributes for a given object of Object Type, type_name.

If you select objects of the same Object Type, an ATTRIBUTE command for that type_name.attribute_name will apply to all such objects you reference in that session.

ALI[AS] alias

Assigns a specified alias to a type_name.attribute_name, which can be used to refer to the type_name.attribute_name in other ATTRIBUTE commands.

CLE[AR]

Resets the display characteristics for the attribute_name. The format specification must be a text constant such as A10 or $9,999--not a variable.

FOR[MAT] format

Specifies the display format of the column. The format specification must be a text constant such as A10 or $9,999--not a variable.

LIKE {type_name.attribute_name|alias}

Copies the display characteristics of another attribute. LIKE copies only characteristics not defined by another clause in the current ATTRIBUTE command.

ON|OFF

Controls the status of display characteristics for a column. OFF disables the characteristics for an attribute without affecting the characteristics' definition. ON reinstates the characteristics.

Usage

You can enter any number of ATTRIBUTE commands for one or more attributes. All attribute characteristics set for each attribute remain in effect for the remainder of the session, until you turn the attribute OFF, or until you use the CLEAR COLUMN command. Thus, the ATTRIBUTE commands you enter can control an attribute's display characteristics for multiple SQL SELECT commands.

When you enter multiple ATTRIBUTE commands for the same attribute, SQL*Plus applies their clauses collectively. If several ATTRIBUTE commands apply the same clause to the same attribute, the last one entered will control the output.

Examples

To make the LAST_NAME attribute of the Object Type EMPLOYEE_TYPE 20 characters wide, enter

Keyboard icon
ATTRIBUTE EMPLOYEE_TYPE.LAST_NAME FORMAT A20

To format the SALARY attribute of the Object Type EMPLOYEE_TYPE so that it shows millions of dollars, rounds to cents, uses commas to separate thousands, and displays $0.00 when a value is zero, enter

Keyboard icon
ATTRIBUTE EMPLOYEE_TYPE.SALARY FORMAT $9,999,990.99

BREAK

BRE[AK] [ON report_element [action [action]]] ...

where:

report_element

Requires the following syntax:

{column|expr|ROW|REPORT}

action

Requires the following syntax:

[SKI[P] n|[SKI[P]] PAGE][NODUP[LICATES]|DUP[LICATES]]

Specifies where changes occur in a report and the formatting action to perform, such as:

Enter BREAK with no clauses to list the current BREAK definition.

Terms

Refer to the following list for a description of each term or clause:

ON column [action [action]]

When you include action(s), specifies action(s) for SQL*Plus to take whenever a break occurs in the specified column (called the break column). (column cannot have a table or view appended to it. To achieve this, you can alias the column in the SQL statement.) A break is one of three events, a change in the value of a column or expression, the output of a row, or the end of a report

When you omit action(s), BREAK ON column suppresses printing of duplicate values in column and marks a place in the report where SQL*Plus will perform the computation you specify in a corresponding COMPUTE command.

You can specify ON column one or more times. If you specify multiple ON clauses, as in

BREAK ON DEPARTMENT_ID SKIP PAGE ON JOB_ID - 
SKIP 1 ON SALARY SKIP 1

the first ON clause represents the outermost break (in this case, ON DEPARTMENT_ID) and the last ON clause represents the innermost break (in this case, ON SALARY). SQL*Plus searches each row of output for the specified break(s), starting with the outermost break and proceeding--in the order you enter the clauses--to the innermost. In the example, SQL*Plus searches for a change in the value of DEPARTMENT_ID, then JOB_ID, then SALARY.

Next, SQL*Plus executes actions beginning with the action specified for the innermost break and proceeding in reverse order toward the outermost break (in this case, from SKIP 1 for ON SALARY toward SKIP PAGE for ON DEPARTMENT_ID). SQL*Plus executes each action up to and including the action specified for the first occurring break encountered in the initial search.

If, for example, in a given row the value of JOB_ID changes--but the values of DEPARTMENT_ID and SALARY remain the same--SQL*Plus skips two lines before printing the row (one as a result of SKIP 1 ON SALARY and one as a result of SKIP 1 ON JOB_ID).

Whenever you use ON column, you should also use an ORDER BY clause in the SQL SELECT command. Typically, the columns used in the BREAK command should appear in the same order in the ORDER BY clause (although all columns specified in the ORDER BY clause need not appear in the BREAK command). This prevents breaks from occurring at meaningless points in the report.

If the BREAK command specified earlier in this section is used, the following SELECT command produces meaningful results:

SELECT DEPARTMENT_ID, JOB_ID, SALARY, LAST_NAME
FROM EMP_DETAILS_VIEW
WHERE SALARY > 12000
ORDER BY DEPARTMENT_ID, JOB_ID, SALARY, LAST_NAME;

All rows with the same DEPARTMENT_ID print together on one page, and within that page all rows with the same JOB_ID print in groups. Within each group of jobs, those jobs with the same SALARY print in groups. Breaks in LAST_NAME cause no action because LAST_NAME does not appear in the BREAK command.

ON expr [action [action]]

When you include action(s), specifies action(s) for SQL*Plus to take when the value of the expression changes.

When you omit action(s), BREAK ON expr suppresses printing of duplicate values of expr and marks a place in the report where SQL*Plus will perform the computation you specify in a corresponding COMPUTE command.

You can use an expression involving one or more table columns or an alias assigned to a report column in a SQL SELECT or SQL*Plus COLUMN command. If you use an expression in a BREAK command, you must enter expr exactly as it appears in the SELECT command. If the expression in the SELECT command is a+b, for example, you cannot use b+a or (a+b) in a BREAK command to refer to the expression in the SELECT command.

The information given above for ON column also applies to ON expr.

ON ROW [action [action]]

When you include action(s), specifies action(s) for SQL*Plus to take when a SQL SELECT command returns a row. The ROW break becomes the innermost break regardless of where you specify it in the BREAK command. You should always specify an action when you BREAK on a row.

ON REPORT [action]

Marks a place in the report where SQL*Plus will perform the computation you specify in a corresponding COMPUTE command. Use BREAK ON REPORT in conjunction with COMPUTE to print grand totals or other "grand" computed values.

The REPORT break becomes the outermost break regardless of where you specify it in the BREAK command.

Note that SQL*Plus will not skip a page at the end of a report, so you cannot use BREAK ON REPORT SKIP PAGE.

Refer to the following list for a description of each action:

SKI[P] n

Skips n lines before printing the row where the break occurred. BREAK SKIP n does not work in SET MARKUP HTML ON mode or in iSQL*Plus unless PREFORMAT is SET ON.

[SKI[P]] PAGE

Skips the number of lines that are defined to be a page before printing the row where the break occurred. The number of lines per page can be set via the PAGESIZE clause of the SET command. Note that PAGESIZE only changes the number of lines that SQL*Plus considers to be a page. Therefore, SKIP PAGE may not always cause a physical page break, unless you have also specified NEWPAGE 0. Note also that if there is a break after the last row of data to be printed in a report, SQL*Plus will not skip the page.

NODUP[LICATES]

Prints blanks rather than the value of a break column when the value is a duplicate of the column's value in the preceding row.

DUP[LICATES]

Prints the value of a break column in every selected row.

Enter BREAK with no clauses to list the current break definition.

Usage

Each new BREAK command you enter replaces the preceding one.

To remove the BREAK command, use CLEAR BREAKS.

Examples

To produce a report that prints duplicate job values, prints the average of SALARY and inserts one blank line when the value of JOB_ID changes, and additionally prints the sum of SALARY and inserts another blank line when the value of DEPARTMENT_ID changes, you could enter the following commands. (The example selects departments 50 and 80 and the jobs of clerk and salesman only.)

Keyboard icon
BREAK ON DEPARTMENT_ID SKIP 1 ON JOB_ID SKIP 1 DUPLICATES COMPUTE SUM OF SALARY ON DEPARTMENT_ID COMPUTE AVG OF SALARY ON JOB_ID SELECT DEPARTMENT_ID, JOB_ID, LAST_NAME, SALARY FROM EMP_DETAILS_VIEW WHERE JOB_ID IN ('SH_CLERK', 'SA_MAN') AND DEPARTMENT_ID IN (50, 80) ORDER BY DEPARTMENT_ID, JOB_ID; Screen icon
DEPARTMENT_ID JOB_ID LAST_NAME SALARY ------------- ---------- ------------------------- ---------- 50 SH_CLERK Taylor 3200 SH_CLERK Fleaur 3100 . . . SH_CLERK Gates 2900 DEPARTMENT_ID JOB_ID LAST_NAME SALARY ------------- ---------- ------------------------- ---------- 50 SH_CLERK Perkins 2500 SH_CLERK Bell 4000 . . . SH_CLERK Grant 2600 ********** ---------- avg 3215 DEPARTMENT_ID JOB_ID LAST_NAME SALARY ------------- ---------- ------------------------- ---------- ************* ---------- sum 64300 80 SA_MAN Russell 14000 SA_MAN Partners 13500 SA_MAN Errazuriz 12000 SA_MAN Cambrault 11000 SA_MAN Zlotkey 10500 ********** ---------- avg 12200 DEPARTMENT_ID JOB_ID LAST_NAME SALARY ------------- ---------- ------------------------- ---------- ************* ---------- sum 61000 25 rows selected.

BTITLE

BTI[TLE] [printspec [text|variable] ...] [ON|OFF]

where printspec represents one or more of the following clauses used to place and format the text:

COL n

CE[NTER]

S[KIP] [n]

R[IGHT]

TAB n

BOLD

LE[FT]

FORMAT text

Places and formats a specified title at the bottom of each report page, or lists the current BTITLE definition.

For a description of the old form of BTITLE, see Appendix C, "Obsolete SQL*Plus Commands".

Terms

Refer to the TTITLE command in this chapter for information on terms and clauses in the BTITLE command syntax.

Enter BTITLE with no clauses to list the current BTITLE definition.

Usage

If you do not enter a printspec clause before the first occurrence of text, BTITLE left justifies the text. SQL*Plus interprets BTITLE in the new form if a valid printspec clause (LEFT, SKIP, COL, and so on) immediately follows the command name.

Examples

To set a bottom title with CORPORATE PLANNING DEPARTMENT on the left and a date on the right, enter

Keyboard icon
BTITLE LEFT 'CORPORATE PLANNING DEPARTMENT' - RIGHT '1 JAN 2001'

To set a bottom title with CONFIDENTIAL in column 50, followed by six spaces and a date, enter

Keyboard icon
BTITLE COL 50 'CONFIDENTIAL' TAB 6 '1 JAN 2001'

CHANGE

CHANGE is not available in iSQL*Plus.

C[HANGE] sepchar old [sepchar [new [sepchar]]]

Changes the first occurrence of the specified text on the current line in the buffer.

Terms

Refer to the following list for a description of each term or clause:

sepchar

Represents any non-alphanumeric character such as "/" or "!". Use a sepchar that does not appear in old or new.

old

Represents the text you wish to change. CHANGE ignores case in searching for old. For example,

CHANGE /aq/aw

will find the first occurrence of "aq", "AQ", "aQ", or "Aq" and change it to "aw". SQL*Plus inserts the new text exactly as you specify it.

If old is prefixed with "...", it matches everything up to and including the first occurrence of old. If it is suffixed with "...", it matches the first occurrence of old and everything that follows on that line. If it contains an embedded "...", it matches everything from the preceding part of old through the following part of old.

new

Represents the text with which you wish to replace old. If you omit new and, optionally, the second and third sepchars, CHANGE deletes old from the current line of the buffer.

Usage

CHANGE changes the first occurrence of the existing specified text on the current line of the buffer to the new specified text. The current line is marked with an asterisk (*) in the LIST output.

You can also use CHANGE to modify a line in the buffer that has generated an Oracle error. SQL*Plus sets the buffer's current line to the line containing the error so that you can make modifications.

To reenter an entire line, you can type the line number followed by the new contents of the line. If you specify a line number larger than the number of lines in the buffer and follow the number with text, SQL*Plus adds the text in a new line at the end of the buffer. If you specify zero ("0") for the line number and follow the zero with text, SQL*Plus inserts the line at the beginning of the buffer (that line becomes line 1).

Examples

Enter 3 so the current line of the buffer contains the following text:

Keyboard icon
3 Screen icon
3* WHERE JOB_ID IS IN ('CLERK', 'SA_MAN')

Enter the following command:

Keyboard icon
CHANGE /CLERK/SH_CLERK/

The text in the buffer changes as follows:

Screen icon
3* WHERE JOB_ID IN ('SH_CLERK', 'SA_MAN')

Or enter the following command:

Keyboard icon
CHANGE /'CLERK',... /'SH_CLERK'/

The original line changes to

Screen icon
3* WHERE JOB_ID IS IN ('SH_CLERK')

Or enter the following command:

Keyboard icon
CHANGE /(...)/('SA_MAN')/

The original line changes to

Screen icon
3* WHERE JOB_ID IS IN ('SA_MAN')

You can replace the contents of an entire line using the line number. This entry

Keyboard icon
3 WHERE JOB_ID IS IN ('SH_CLERK')

causes the second line of the buffer to be replaced with

WHERE JOB_ID IS IN ('SH_CLERK')

Note that entering a line number followed by a string will replace the line regardless of what text follows the line number. For example,

Keyboard icon
2 CHANGE/OLD/NEW/

will change the second line of the buffer to be

Screen icon
2* C/OLD/NEW/

CLEAR

CL[EAR] option ...

where option represents one of the following clauses:

BRE[AKS]
BUFF[ER]
COL[UMNS]
COMP[UTES]
SCR[EEN]
SQL
TIMI[NG]

Resets or erases the current value or setting for the specified option.

Terms

Refer to the following list for a description of each term or clause:

BRE[AKS]

Removes the break definition set by the BREAK command.

BUFF[ER]

Clears text from the buffer. CLEAR BUFFER has the same effect as CLEAR SQL, unless you are using multiple buffers (see the SET BUFFER command in Appendix C, "Obsolete SQL*Plus Commands").

COL[UMNS]

Resets column display attributes set by the COLUMN command to default settings for all columns. To reset display attributes for a single column, use the CLEAR clause of the COLUMN command. CLEAR COLUMNS also clears the ATTRIBUTEs for that column.

COMP[UTES]

Removes all COMPUTE definitions set by the COMPUTE command.

SCR[EEN]

Clears your screen.

CLEAR SCREEN is not available in iSQL*Plus.

SQL

Clears the text from SQL buffer. CLEAR SQL has the same effect as CLEAR BUFFER, unless you are using multiple buffers (see the SET BUFFER command in Appendix C, "Obsolete SQL*Plus Commands").

TIMI[NG]

Deletes all timers created by the TIMING command.

Examples

To clear breaks, enter

Keyboard icon
CLEAR BREAKS

To clear column definitions, enter

Keyboard icon
CLEAR COLUMNS

COLUMN

COL[UMN] [{column|expr} [option ...]]

where option represents one of the following clauses:

ALI[AS] alias
CLE[AR]
ENTMAP {ON|OFF}
FOLD_A[FTER]
FOLD_B[EFORE]
FOR[MAT] format
HEA[DING] text
JUS[TIFY] {L[EFT]|C[ENTER]|C[ENTRE]|R[IGHT]}
LIKE {expr|alias}
NEWL[INE]
NEW_V[ALUE] variable
NOPRI[NT]|PRI[NT]
NUL[L] text
OLD_V[ALUE] variable
ON|OFF
WRA[PPED]|WOR[D_WRAPPED]|TRU[NCATED]

Specifies display attributes for a given column, such as

Also lists the current display attributes for a single column or all columns.

Terms

Enter COLUMN followed by column or expr and no other clauses to list the current display attributes for only the specified column or expression. Enter COLUMN with no clauses to list all current column display attributes.

Refer to the following list for a description of each term or clause:

{column|expr}

Identifies the data item (typically, the name of a column) in a SQL SELECT command to which the column command refers. If you use an expression in a COLUMN command, you must enter expr exactly as it appears in the SELECT command. If the expression in the SELECT command is a+b, for example, you cannot use b+a or (a+b) in a COLUMN command to refer to the expression in the SELECT command.

If you select columns with the same name from different tables, a COLUMN command for that column name will apply to both columns. That is, a COLUMN command for the column LAST_NAME applies to all columns named LAST_NAME that you reference in this session. COLUMN ignores table name prefixes in SELECT commands. Also, spaces are ignored unless the name is placed in double quotes.

To format the columns differently, assign a unique alias to each column within the SELECT command itself (do not use the ALIAS clause of the COLUMN command) and enter a COLUMN command for each column's alias.

ALI[AS] alias

Assigns a specified alias to a column, which can be used to refer to the column in BREAK, COMPUTE, and other COLUMN commands.

CLE[AR]

Resets the display attributes for the column to default values.

To reset the attributes for all columns, use the CLEAR COLUMNS command. CLEAR COLUMNS also clears the ATTRIBUTEs for that column.

ENTMAP {ON|OFF}

Allows entity mapping to be turned on or off for selected columns in HTML output. This feature allows you to include, for example, HTML hyperlinks in a column of data, while still mapping entities in other columns of the same report. By turning entity mapping off for a column containing HTML hyperlinks, the HTML anchor tag delimiters, <, >, " and &, are correctly interpreted in the report. Otherwise they would be replaced with their respective entities, &lt;, &gt;, &quot; and &amp;, preventing web browsers from correctly interpreting the HTML.

Entities in the column heading and any COMPUTE labels or output appearing in the column are mapped or not mapped according to the value of ENTMAP for the column.

The default setting for COLUMN ENTMAP is the current setting of the MARKUP HTML ENTMAP option. For more information about the MARKUP HTML ENTMAP option, see SET "MARKUP Options" and SET later this Chapter.

FOLD_A[FTER]

Inserts a carriage return after the column heading and after each row in the column. SQL*Plus does not insert an extra carriage return after the last column in the SELECT list.

FOLD_B[EFORE]

Inserts a carriage return before the column heading and before each row of the column. SQL*Plus does not insert an extra carriage return before the first column in the SELECT list.

FOR[MAT] format

Specifies the display format of the column. The format specification must be a text constant such as A10 or $9,999--not a variable.

Character Columns The default width of CHAR, NCHAR, VARCHAR2 (VARCHAR) and NVARCHAR2 (NCHAR VARYING) columns is the width of the column in the database. SQL*Plus formats these datatypes left-justified. If a value does not fit within the column width, SQL*Plus wraps or truncates the character string depending on the setting of SET WRAP.

A LONG, CLOB, NCLOB or XMLType column's width defaults to the value of SET LONGCHUNKSIZE or SET LONG, whichever one is smaller.

To change the width of a datatype to n, use FORMAT An. (A stands for alphanumeric.) If you specify a width shorter than the column heading, SQL*Plus truncates the heading.

DATE Columns The default width and format of unformatted DATE columns in SQL*Plus is derived from the NLS parameters in effect. Otherwise, the default width is A9. In Oracle9i, the NLS parameters may be set in your database parameter file or may be environment variables or an equivalent platform-specific mechanism. They may also be specified for each session with the ALTER SESSION command. (See the documentation for Oracle9i for a complete description of the NLS parameters).

You can change the format of any DATE column using the SQL function TO_CHAR in your SQL SELECT statement. You may also wish to use an explicit COLUMN FORMAT command to adjust the column width.

When you use SQL functions like TO_CHAR, Oracle automatically allows for a very wide column.

To change the width of a DATE column to n, use the COLUMN command with FORMAT An. If you specify a width shorter than the column heading, the heading is truncated.

NUMBER Columns To change a NUMBER column's width, use FORMAT followed by an element as specified in Table 13-1.

Table 13-1 Number Formats
Element Examples Description

9

9999

Number of "9"s specifies number of significant digits returned. Blanks are displayed for leading zeroes. A zero (0) is displayed for a value of zero.

0

0999
9990

Displays a leading zero or a value of zero in this position as 0.

$

$9999

Prefixes value with dollar sign.

B

B9999

Displays a zero value as blank, regardless of "0"s in the format model.

MI

9999MI

Displays "-" after a negative value. For a positive value, a trailing space is displayed.

S

S9999

Returns "+" for positive values and "-" for negative values in this position.

PR

9999PR

Displays a negative value in <angle brackets>. For a positive value, a leading and trailing space is displayed.

D

99D99

Displays the decimal character in this position, separating the integral and fractional parts of a number.

G

9G999

Displays the group separator in this position.

C

C999

Displays the ISO currency symbol in this position.

L

L999

Displays the local currency symbol in this position.

, (comma)

9,999

Displays a comma in this position.

. (period)

99.99

Displays a period (decimal point) in this position, separating the integral and fractional parts of a number.

V

999V99

Multiplies value by 10n, where n is number of "9"s after "V".

EEEE

9.999EEEE

Displays value in scientific notation (format must contain exactly four "E"s).

RN or rn

RN

Displays upper- or lowercase Roman numerals. Value can be an integer between 1 and 3999.

DATE

DATE

Displays value as a date in MM/DD/YY format; used to format NUMBER columns that represent Julian dates.

The MI and PR format elements can only appear in the last position of a number format model. The S format element can only appear in the first or last position.

If a number format model does not contain the MI, S or PR format elements, negative return values automatically contain a leading negative sign and positive values automatically contain a leading space.

A number format model can contain only a single decimal character (D) or period (.), but it can contain multiple group separators (G) or commas (,). A group separator or comma cannot appear to the right of a decimal character or period in a number format model.

SQL*Plus formats NUMBER data right-justified. A NUMBER column's width equals the width of the heading or the width of the FORMAT plus one space for the sign, whichever is greater. If you do not explicitly use FORMAT, then the column's width will always be at least the value of SET NUMWIDTH.

SQL*Plus may round your NUMBER data to fit your format or field width.

If a value cannot fit within the column width, SQL*Plus indicates overflow by displaying a pound sign (#) in place of each digit the width allows.

If a positive value is extremely large and a numeric overflow occurs when rounding a number, then the infinity sign (~) replaces the value. Likewise, if a negative value is extremely small and a numeric overflow occurs when rounding a number, then the negative infinity sign replaces the value (-~).

HEA[DING] text

Defines a column heading. If you do not use a HEADING clause, the column's heading defaults to column or expr. If text contains blanks or punctuation characters, you must enclose it with single or double quotes. Each occurrence of the HEADSEP character (by default, "|") begins a new line.

For example,

COLUMN LAST_NAME HEADING 'Employee |Name'

would produce a two-line column heading. See the HEADSEP variable of the SET command in this chapter for information on changing the HEADSEP character.

JUS[TIFY] {L[EFT]|C[ENTER]|C[ENTRE]|R[IGHT]}

Aligns the heading. If you do not use a JUSTIFY clause, headings for NUMBER columns default to RIGHT and headings for other column types default to LEFT.

LIKE {expr|alias}

Copies the display attributes of another column or expression (whose attributes you have already defined with another COLUMN command). LIKE copies only attributes not defined by another clause in the current COLUMN command.

NEWL[INE]

Starts a new line before displaying the column's value. NEWLINE has the same effect as FOLD_BEFORE.

NEW_V[ALUE] variable

Specifies a variable to hold a column value. You can reference the variable in TTITLE commands. Use NEW_VALUE to display column values or the date in the top title. You must include the column in a BREAK command with the SKIP PAGE action. The variable name cannot contain a pound sign (#).

NEW_VALUE is useful for master/detail reports in which there is a new master record for each page. For master/detail reporting, you must also include the column in the ORDER BY clause. See the example at the end of this command description.

For information on displaying a column value in the bottom title, see COLUMN OLD_VALUE. For more information on referencing variables in titles, see the TTITLE command later in this chapter. For information on formatting and valid format models, see COLUMN FORMAT command.

NOPRI[NT]|PRI[NT]

Controls the printing of the column (the column heading and all the selected values). NOPRINT turns off the screen output and printing of the column. PRINT turns the printing of the column on.

NUL[L] text

Controls the text SQL*Plus displays for null values in the given column. The default is a white space. SET NULL controls the text displayed for all null values for all columns, unless overridden for a specific column by the NULL clause of the COLUMN command. When a NULL value is SELECTed, a variable's type will always become CHAR so the SET NULL text can be stored in it.

OLD_V[ALUE] variable

Specifies a variable to hold a column value. You can reference the variable in BTITLE commands. Use OLD_VALUE to display column values in the bottom title. You must include the column in a BREAK command with the SKIP PAGE action.

OLD_VALUE is useful for master/detail reports in which there is a new master record for each page. For master/detail reporting, you must also include the column in the ORDER BY clause.

For information on displaying a column value in the top title, see COLUMN NEW_VALUE. For more information on referencing variables in titles, see the TTITLE command later in this chapter.

ON|OFF

Controls the status of display attributes for a column. OFF disables the attributes for a column without affecting the attributes' definition. ON reinstates the attributes.

WRA[PPED]|WOR[D_WRAPPED]|TRU[NCATED]

Specifies how SQL*Plus will treat a datatype or DATE string that is too wide for a column. WRAPPED wraps the string within the column bounds, beginning new lines when required. When WORD_WRAP is enabled, SQL*Plus left justifies each new line, skipping all leading whitespace (for example, returns, newline characters, tabs and spaces), including embedded newline characters. Embedded whitespace not on a line boundary is not skipped. TRUNCATED truncates the string at the end of the first line of display.

Usage

You can enter any number of COLUMN commands for one or more columns. All column attributes set for each column remain in effect for the remainder of the session, until you turn the column OFF, or until you use the CLEAR COLUMN command. Thus, the COLUMN commands you enter can control a column's display attributes for multiple SQL SELECT commands.

When you enter multiple COLUMN commands for the same column, SQL*Plus applies their clauses collectively. If several COLUMN commands apply the same clause to the same column, the last one entered will control the output.

Examples

To make the LAST_NAME column 20 characters wide and display EMPLOYEE NAME on two lines as the column heading, enter

Keyboard icon
COLUMN LAST_NAME FORMAT A20 HEADING 'EMPLOYEE|NAME'

To format the SALARY column so that it shows millions of dollars, rounds to cents, uses commas to separate thousands, and displays $0.00 when a value is zero, enter

Keyboard icon
COLUMN SALARY FORMAT $9,999,990.99

To assign the alias NET to a column containing a long expression, to display the result in a dollar format, and to display <NULL> for null values, you might enter


Keyboard icon
COLUMN SALARY+COMMISSION_PCT+BONUS-EXPENSES-INS-TAX ALIAS NET COLUMN NET FORMAT $9,999,999.99 NULL '<NULL>'

Note that the example divides this column specification into two commands. The first defines the alias NET, and the second uses NET to define the format.

Also note that in the first command you must enter the expression exactly as you enter it in the SELECT command. Otherwise, SQL*Plus cannot match the COLUMN command to the appropriate column.

To wrap long values in a column named REMARKS, you can enter

Keyboard icon
COLUMN REMARKS FORMAT A20 WRAP Screen icon
CUSTOMER DATE QUANTITY REMARKS ---------- --------- -------- -------------------- 123 25-AUG-2001 144 This order must be s hipped by air freigh t to ORD

If you replace WRAP with WORD_WRAP, REMARKS looks like this:

CUSTOMER   DATE        QUANTITY REMARKS
---------- ---------   -------- ---------------------
123        25-AUG-2001      144 This order must be
                                shipped by air freight
                                to ORD

If you specify TRUNCATE, REMARKS looks like this:

CUSTOMER   DATE        QUANTITY REMARKS
---------- ---------   -------- --------------------
123        25-AUG-2001      144 This order must be s

In order to print the current date and the name of each job in the top title, enter the following. Use the EMPLOYEES table of the HR schema in this case instead of EMP_DETAILS_VIEW as you have used up to now. (For details on creating a date variable, see "Displaying the Current Date in Titles" under "Defining Page and Report Titles and Dimensions".)

Keyboard icon
COLUMN JOB_ID NOPRINT NEW_VALUE JOBVAR COLUMN TODAY NOPRINT NEW_VALUE DATEVAR BREAK ON JOB_ID SKIP PAGE ON TODAY TTITLE CENTER 'Job Report' RIGHT DATEVAR SKIP 2 - LEFT 'Job: ' JOBVAR SKIP 2 SELECT TO_CHAR(SYSDATE, 'MM/DD/YYYY') TODAY, LAST_NAME, JOB_ID, MANAGER_ID, HIRE_DATE, SALARY, DEPARTMENT_ID FROM EMPLOYEES WHERE JOB_ID IN ('MK_MAN', 'SA_MAN') ORDER BY JOB_ID, LAST_NAME;

Your two page report would look similar to the following report, with "Job Report" centered within your current linesize:

Screen icon
Job Report 04/19/01 Job: MK_MAN LAST NAME MANAGER_ID HIRE_DATE SALARY DEPARTMENT_ID -------------------- ---------- --------- -------------- ------------- Hartstein 100 17-FEB-96 $13,000.00 20 -------------- $13,000.00 Job Report 04/19/01 Job: SA_MAN LAST NAME MANAGER_ID HIRE_DATE SALARY DEPARTMENT_ID -------------------- ---------- --------- -------------- ------------- Errazuriz 100 10-MAR-97 $12,000.00 80 Zlotkey 100 29-JAN-00 $10,500.00 80 Cambrault 100 15-OCT-99 $11,000.00 80 Russell 100 01-OCT-96 $14,000.00 80 Partners 100 05-JAN-97 $13,500.00 80 -------------- Job Report 04/19/01 Job: SA_MAN LAST NAME MANAGER_ID HIRE_DATE SALARY DEPARTMENT_ID -------------------- ---------- --------- -------------- ------------- $12,200.00 6 rows selected.

To change the default format of DATE columns to 'YYYY-MM-DD', you can enter

Keyboard icon
ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD'; Screen icon
Session altered.

To display the change, enter a SELECT statement, such as:

Keyboard icon
SELECT HIRE_DATE FROM EMPLOYEES WHERE EMPLOYEE_ID = 206; Screen icon
Job Report 04/19/01 Job: SA_MAN HIRE_DATE ---------- 1994-06-07

See the Oracle9i SQL Reference for information on the ALTER SESSION command.

Note that in a SELECT statement, some SQL calculations or functions, such as TO_CHAR, may cause a column to be very wide. In such cases, use the FORMAT option to alter the column width.

COMPUTE

COMP[UTE] [function [LAB[EL] text] ...
OF {expr|column|alias} ...
ON {expr|column|alias|REPORT|ROW} ...]

Calculates and prints summary lines, using various standard computations, on subsets of selected rows. It also lists all COMPUTE definitions. For details on how to create summaries, see "Clarifying Your Report with Spacing and Summary Lines".

Terms

Refer to the following list for a description of each term or clause:

function ...

Represents one of the functions listed in Table 13-2. If you specify more than one function, use spaces to separate the functions.

COMPUTE command functions are always executed in the sequence AVG, COUNT, MINIMUM, MAXIMUM, NUMBER, SUM, STD, VARIANCE, regardless of their order in the COMPUTE command.

Table 13-2 COMPUTE Functions
Function Computes Applies to Datatypes
AVG

Average of non-null values

NUMBER

COU[NT]

Count of non-null values

all types

MIN[IMUM]

Minimum value

NUMBER, CHAR, NCHAR, VARCHAR2 (VARCHAR), NVARCHAR2 (NCHAR VARYING)

MAX[IMUM]

Maximum value

NUMBER, CHAR, NCHAR, VARCHAR2 (VARCHAR), NVARCHAR2 (NCHAR VARYING)

NUM[BER]