SQL*Plus User's Guide and Reference
Release 8.1.6
A75664-01

Library

Product

Contents

Index

PrevUpNext

Command Reference, 40 of 52


SET

Purpose

Sets a system variable to alter the SQL*Plus environment for your current session, such as

Syntax

SET system_variable value

where system_variable and value represent one of the following clauses.

APPI[NFO]{ON|OFF|text}
ARRAY[SIZE] {15|n}
AUTO[COMMIT]{ON|OFF|IMM[EDIATE]|n}
AUTOP[RINT] {ON|OFF}
AUTORECOVERY [ON|OFF]
AUTOT[RACE] {ON|OFF|TRACE[ONLY]} [EXP[LAIN]] [STAT[ISTICS]]
BLO[CKTERMINATOR] {.|c}
CMDS[EP] {;|c|ON|OFF}
COLSEP {_|text}
COM[PATIBILITY]{V7|V8|NATIVE}
CON[CAT] {.|c|ON|OFF}
COPYC[OMMIT] {0|n}
COPYTYPECHECK {ON|OFF}
DEF[INE] {&|c|ON|OFF}
DESCRIBE [DEPTH {1|n|ALL}][LINENUM {ON|OFF}][INDENT {ON|OFF}]
ECHO {ON|OFF}
EDITF[ILE] file_name[.ext]
EMB[EDDED] {ON|OFF}
ESC[APE] {\|c|ON|OFF}
FEED[BACK] {6|n|ON|OFF}
FLAGGER {OFF|ENTRY |INTERMED[IATE]|FULL}
FLU[SH] {ON|OFF}
HEA[DING] {ON|OFF}
HEADS[EP] {||c|ON|OFF}
INSTANCE [instance_path|LOCAL]
LIN[ESIZE] {80|n}
LOBOF[FSET] {n|1}
LOGSOURCE [pathname]
LONG {80|n}
LONGC[HUNKSIZE] {80|n}
MARK[UP] HTML [ON|OFF] [HEAD text] [BODY text] [ENTMAP {ON|OFF}] [SPOOL 
{ON|OFF}] [PRE[FORMAT] {ON|OFF}]
NEWP[AGE] {1|n|NONE}
NULL text
NUMF[ORMAT] format
NUM[WIDTH] {10|n}
PAGES[IZE] {24|n}
PAU[SE] {ON|OFF|text}
RECSEP {WR[APPED]|EA[CH]|OFF}
RECSEPCHAR {_|c}
SERVEROUT[PUT] {ON|OFF} [SIZE n] [FOR[MAT] {WRA[PPED]|WOR[D_
WRAPPED]|TRU[NCATED]}]
SHIFT[INOUT] {VIS[IBLE]|INV[ISIBLE]}
SHOW[MODE] {ON|OFF}
SQLBL[ANKLINES] {ON|OFF}
SQLC[ASE] {MIX[ED]|LO[WER]|UP[PER]}
SQLCO[NTINUE] {> |text}
SQLN[UMBER] {ON|OFF}
SQLPRE[FIX] {#|c}
SQLP[ROMPT] {SQL>|text}
SQLT[ERMINATOR] {;|c|ON|OFF}
SUF[FIX] {SQL|text}
TAB {ON|OFF}
TERM[OUT] {ON|OFF}
TI[ME] {ON|OFF}
TIMI[NG] {ON|OFF}
TRIM[OUT] {ON|OFF}
TRIMS[POOL] {ON|OFF}
UND[ERLINE] {-|c|ON|OFF}
VER[IFY] {ON|OFF}
WRA[P] {ON|OFF}

Terms and Clauses

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

APPI[NFO]{ON|OFF|text}
ARRAY[SIZE] {15|n}
AUTO[COMMIT]{ON|OFF|IMM[EDIATE]|n}
n INSERT, UPDATE or DELETE commands or PL/SQL blocksa commita rollbacka SET AUTOCOMMIT command 

Note:

For this feature, a PL/SQL block is considered one transaction, regardless of the actual number of SQL commands contained within it. 



 
AUTOP[RINT] {ON|OFF}
AUTORECOVERY [ON|OFF]
AUTOT[RACE] {ON|OFF|TRACE[ONLY]} [EXP[LAIN]] [STAT[ISTICS]]
BLO[CKTERMINATOR] {.|c}
CMDS[EP] {;|c|ON|OFF}
COLSEP {_|text}
COM[PATIBILITY]{V7|V8|NATIVE}
CON[CAT] {.|c|ON|OFF}
COPYC[OMMIT] {0|n}
COPYTYPECHECK {ON|OFF}
DEF[INE] {&|c|ON|OFF}
DESCRIBE [DEPTH {1|n|ALL}][LINENUM {ON|OFF}][INDENT {ON|OFF}]
ECHO {ON|OFF}
EDITF[ILE] file_name[.ext]
EMB[EDDED] {ON|OFF}
ESC[APE] {\|c|ON|OFF}
FEED[BACK] {6|n|ON|OFF}
FLAGGER {OFF|ENTRY |INTERMED[IATE]|FULL}
FLU[SH] {ON|OFF}
HEA[DING] {ON|OFF}
HEADS[EP] {||c|ON|OFF}
INSTANCE [instance_path|LOCAL]
LIN[ESIZE] {80|n}
LOBOF[FSET] {n|1}
LOGSOURCE [pathname]
LONG {80|n}
LONGC[HUNKSIZE] {80|n}
MARK[UP] HTML [ON|OFF] [HEAD text] [BODY text] [ENTMAP {ON|OFF}]

[SPOOL {ON|OFF}] [PRE[FORMAT] {ON|OFF}]
NEWP[AGE] {1|n|NONE}
NULL text
NUMF[ORMAT] format
NUM[WIDTH] {10|n}
PAGES[IZE] {24|n}
PAU[SE] {ON|OFF|text}
RECSEP {WR[APPED]|EA[CH]|OFF}

RECSEPCHAR {_|c}
SERVEROUT[PUT] {ON|OFF} [SIZE n] [FOR[MAT]

{WRA[PPED]|WOR[D_WRAPPED]|TRU[NCATED]}]
SHIFT[INOUT] {VIS[IBLE]|INV[ISIBLE]}
SHOW[MODE] {ON|OFF}
SQLBL[ANKLINES] {ON|OFF}
SQLC[ASE] {MIX[ED]|LO[WER]|UP[PER]}
uppercase if SQLCASE equals UPPERlowercase if SQLCASE equals LOWERunchanged if SQLCASE equals MIXED
SQLCO[NTINUE] {> |text}
SQLN[UMBER] {ON|OFF}
SQLPRE[FIX] {#|c}
SQLP[ROMPT] {SQL>|text}
SQLT[ERMINATOR] {;|c|ON|OFF}
SUF[FIX] {SQL|text}
TAB {ON|OFF}
TERM[OUT] {ON|OFF}
TI[ME] {ON|OFF}
TIMI[NG] {ON|OFF}
TRIM[OUT] {ON|OFF}
TRIMS[POOL] {ON|OFF}
UND[ERLINE] {-|c|ON|OFF}
VER[IFY] {ON|OFF}
WRA[P] {ON|OFF}

Usage Notes

SQL*Plus maintains system variables (also called SET command variables) to allow you to establish a particular environment for a SQL*Plus session. You can change these system variables with the SET command and list them with the SHOW command.

SET ROLE and SET TRANSACTION are SQL commands (see the Oracle8i SQL Reference for more information). When not followed by the keywords TRANSACTION or ROLE, SET is assumed to be a SQL*Plus command.

Examples

The following examples show sample uses of selected SET command variables.

APPINFO

To display the setting of APPINFO, enter

SQL> SHOW APPINFO
SQL> appinfo is ON and set to "SQL*Plus"

To change the default text, enter

SQL> SET APPI 'This is SQL*Plus'
SQL> SHOW APPINFO
SQL> appinfo is ON and set to "This is SQL*Plus"

To make sure that registration has taken place, enter
SQL> VARIABLE MOD VARCHAR2(50)
SQL> VARIABLE ACT VARCHAR2(40)
SQL> EXECUTE DBMS_APPLICATION_INFO.READ_MODULE(:MOD, :ACT);
SQL> PRINT MOD
MOD
---------------------------------------------------
This is SQL*Plus
AUTORECOVERY

To set the recovery mode to AUTOMATIC, enter

SQL> SET AUTORECOVERY ON
SQL> RECOVER DATABASE
CMDSEP

To specify a TTITLE and format a column on the same line, enter

SQL> SET CMDSEP +
SQL> TTITLE LEFT 'SALARIES' + COLUMN SAL FORMAT $9,999
SQL> SELECT ENAME, SAL FROM EMP
  2  WHERE JOB = 'CLERK';

The following output results:

SALARIES
ENAME          SAL
---------- -------
SMITH         $800
ADAMS       $1,100
JAMES         $950
MILLER      $1,300
COLSEP

To set the column separator to "|" enter

SQL> SET COLSEP '|'
SQL> SELECT ENAME, JOB, DEPTNO
  2  FROM EMP
  3  WHERE DEPTNO = 20;

The following output results:

ENAME     |JOB      |    DEPTNO
-------------------------------
SMITH     |CLERK    |        20
JONES     |MANAGER  |        20
SCOTT     |ANALYST  |        20
ADAMS     |CLERK    |        20
FORD      |ANALYST  |        20
COMPATIBILITY

To run a command file, SALARY.SQL, created with Oracle7, enter

SQL> SET COMPATIBILITY V7
SQL> START SALARY

After running the file, reset compatibility to V8 to run command files created with Oracle8i:

SQL> SET COMPATIBILITY V8

Alternatively, you can add the command SET COMPATIBILITY V7 to the beginning of the command file, and reset COMPATIBILITY to V8 at the end of the file.

DESCRIBE

To describe the object emp_object to a depth of two levels, and indent the output while also displaying line numbers, first describe the object as follows:

SQL> DESCRIBE emp_object

The following output results:

 Name                                      Null     Type
 ----------------------------------------- -------- ----------------------------
 EMPLOYEE                                           RECUR_PERSON
 NAME                                               VARCHAR2(20)
 ADDR                                               RECUR_ADDRESS
 ADDR1                                              RECUR_ADDRESS1
 DOB                                                DATE
 GENDER                                             VARCHAR2(10)
 DEPT                                               RECUR_DEPARTMENT
 DEPTNO                                             NUMBER
 DEPT_NAME                                          VARCHAR2(20)
 LOCATION                                           VARCHAR2(20)
 START_DATE                                         DATE
 POSITION                                           VARCHAR2(1)
 SAL                                                RECUR_SALARY
 ANNUAL_SAL                                         NUMBER(10,2)
 EMP_TYPE                                           VARCHAR2(1)
 COMM                                               NUMBER(10,2)
 PENALTY_RATE                                       NUMBER(5,2)

To format emp_object so that the output displays with indentation and line numbers, use the SET DESCRIBE command as follows:

SQL> SET DESCRIBE DEPTH 2 LINENUM ON INDENT ON

To display the above settings, enter

SQL> DESCRIBE emp_object

The following output results:

           Name                           Null     Type
           ------------------------------  -------- ----------------------------
    1      EMPLOYEE                                 RECUR_PERSON
    2    1   NAME                                   VARCHAR2(20)
    3    1   ADDR                                   RECUR_ADDRESS
    4    1   ADDR1                                  RECUR_ADDRESS1
    5    1   DOB                                    DATE
    6    1   GENDER                                 VARCHAR2(10)
    7      DEPT                                     RECUR_DEPARTMENT
    8    7   DEPTNO                                 NUMBER
    9    7   DEPT_NAME                              VARCHAR2(20)
   10    7   LOCATION                               VARCHAR2(20)
   11      START_DATE                               DATE
   12      POSITION                                 VARCHAR2(1)
   13      SAL                                      RECUR_SALARY
   14   13   ANNUAL_SAL                             NUMBER(10,2)
   15   13   EMP_TYPE                               VARCHAR2(1)
   16   13   COMM                                   NUMBER(10,2)
   17   13   PENALTY_RATE                           NUMBER(5,2)
ESCAPE

If you define the escape character as an exclamation point (!), then

SQL> SET ESCAPE !
SQL> ACCEPT v1 PROMPT 'Enter !&1:'

displays this prompt:

Enter &1:
HEADING

To suppress the display of column headings in a report, enter

SQL> SET HEADING OFF

If you then run a SQL SELECT command,

SQL> SELECT ENAME, SAL FROM EMP
  2  WHERE JOB = 'CLERK';

the following output results:

ADAMS            1100
JAMES             950
MILLER           1300
INSTANCE

To set the default instance to "PROD1" enter

SQL> SET INSTANCE PROD1

To set the instance back to the default or local, enter

SQL> SET INSTANCE local
LOBOFFSET

To set the starting position from which a CLOB column's data is retrieved to the 22nd position, enter

SQL> SET LOBOFFSET 22

The CLOB data will wrap on your screen; SQL*Plus will not truncate until the 23rd character.

LOGSOURCE

To set the default location of log files for recovery to the directory "/usr/oracle81/dbs/arch" enter

SQL> SET LOGSOURCE "/usr/oracle81/dbs/arch" 
SQL> RECOVER DATABASE
LONG

To set the maximum number of characters to fetch for displaying and copying LONG values to 500, enter

SQL> SET LONG 500

The LONG data will wrap on your screen; SQL*Plus will not truncate until the 501st character.

LONGCHUNKSIZE

To set the size of the increments in which SQL*Plus retrieves LONG values to 100 characters, enter

SQL> SET LONGCHUNKSIZE 100

The LONG data will be retrieved in increments of 100 characters until the entire value is retrieved or the value of SET LONG is reached, whichever is the smaller.

MARKUP

To output HTML marked up text to a spool file, enter 


Note:

The SET MARKUP example command is laid out for readability, command options are concatenated in normal entry.

You can also use the SQL*Plus line continuation character '-' to lay out your command. 



 
SQL> SET MARKUP HTML ON
         HEAD '<TITLE>HTML output from SQL*Plus</TITLE>'
         BODY '<H1>Employee Report</H1>
               <P>This is an employee report generated with
               <BR><BLOCKQUOTE>select empno, ename, job
               <BR>from emp;</BLOCKQUOTE><BR>
         <H2>Monthly Employee Report</H2>
         <BLOCKQUOTE>'
         SPOOL ON PREFORMAT ON"
         SCOTT/TIGER
SQL&gt; SET MARKUP HTML ENTMAP OFF
SQL> SPOOL employee.html
SQL> SELECT EMPNO, ENAME, JOB
  2  FROM EMP;

          EMPNO ENAME      JOB
--------------- ---------- ---------
           7839 KING       PRESIDENT
           7698 BLAKE      MANAGER
           7782 CLARK      MANAGER
           7566 JONES      MANAGER

4 rows selected.

SQL> SPOOL OFF

The previous SQL*Plus session generates the following HTML output in the spool file employee.html:

<HTML>
<HEAD>
<TITLE>HTML output from SQL*Plus</TITLE>
<META Name="generator" content="SQL*Plus 8.1.6">
</HEAD>
<BODY <H1>Employee Report</H1><P>This is an employee report generated 
with<BR><BLOCKQUOTE>select empno, ename, job<BR>from emp;
</BLOCKQUOTE><BR><H2>Monthly Employee Report</H2><BLOCKQUOTE>
<PRE>

     EMPNO ENAME      JOB
---------- ---------- ---------
      7839 KING       PRESIDENT
      7698 BLAKE      MANAGER
      7782 CLARK      MANAGER
      7566 JONES      MANAGER

4 rows selected.

</PRE></BODY></HTML>
SQL> SPOOL OFF
SERVEROUTPUT

To enable the display of text within a PL/SQL block using DBMS_OUTPUT.PUT_LINE, enter

SQL> SET SERVEROUTPUT ON

The following example shows what happens when you execute an anonymous procedure with SET SERVEROUTPUT ON:

SQL> BEGIN
  2  DBMS_OUTPUT.PUT_LINE('Task is complete');
  3  END;
  4  /
Task is complete.

PL/SQL procedure successfully completed.

The following example shows what happens when you create a trigger with SET SERVEROUTPUT ON:

SQL> CREATE TRIGGER SERVER_TRIG BEFORE INSERT OR UPDATE -
>    OR DELETE
  2  ON SERVER_TAB
  3  BEGIN
  4  DBMS_OUTPUT.PUT_LINE('Task is complete.');
  5  END;
  6  /
Trigger created.
SQL> INSERT INTO SERVER_TAB VALUES ('TEXT');
Task is complete.
1 row created.

To set the output to WORD_WRAPPED, enter

SQL> SET SERVEROUTPUT ON FORMAT WORD_WRAPPED
SQL> SET LINESIZE 20
SQL> BEGIN
  2  DBMS_OUTPUT.PUT_LINE('If there is nothing left to do');
  3  DBMS_OUTPUT.PUT_LINE('shall we continue with plan B?');
  4  end;
  5  /
If there is nothing
left to do
shall we continue
with plan B?

To set the output to TRUNCATED, enter

SQL> SET SERVEROUTPUT ON FORMAT TRUNCATED
SQL> SET LINESIZE 20
SQL> BEGIN
  2  DBMS_OUTPUT.PUT_LINE('If there is nothing left to do');
  3  DBMS_OUTPUT.PUT_LINE('shall we continue with plan B?');
  4  END;
  5  /
If there is nothing
shall we continue wi
SHIFTINOUT

To enable the display of shift characters, enter

SQL> SET SHIFTINOUT VISIBLE
SQL> SELECT ENAME, JOB FROM EMP;

The following output results:

ENAME      JOB
---------- ----------
:JJOO:     :AABBCC:
:AA:abc    :DDEE:e

where ":" = shift character

uppercase = multibyte character

lowercase = singlebyte character
 


Note:

This example illustrates that the columns are aligned correctly. The data used in this example is an illustration only and does not represent real data. 



 
SQLBLANKLINES

To preserve blank lines in a SQL statement, enter

SQL> SET SQLBLANKLINES ON
SQL> REM Using the SQLTERMINATOR (default is ";") 
SQL> REM Could have used the BLOCKTERMINATOR (default is ".")
SQL> SELECT *
  2  
  3  FROM
  4  
  5  DUAL
  6
  7 ;

The following output results:

D
-
X
SQLCONTINUE

To set the SQL*Plus command continuation prompt to an exclamation point followed by a space, enter

SQL> SET SQLCONTINUE '! '

SQL*Plus will prompt for continuation as follows:

SQL> TTITLE 'YEARLY INCOME' -
! RIGHT SQL.PNO SKIP 2 -
! CENTER 'PC DIVISION'
SQL>
SUFFIX

To change the default command-file extension from the default, .SQL to .UFI, enter

SQL> SET SUFFIX UFI

If you then enter

SQL> GET EXAMPLE


SQL*Plus will look for a file named EXAMPLE with an extension of UFI instead of EXAMPLE with an extension of SQL.


Prev Up Next
Oracle
Copyright © 1999 Oracle Corporation.
All Rights Reserved.

Library

Product

Contents

Index