user3636943
user3636943

Reputation: 129

Oracle set multiple system variables

Is it possible to set multiple system variables in a single command?

For e.g. set the below system variables in a single line?

SET COLSEP '    '
SET ECHO OFF
SET FEEDBACK OFF
SET HEADING OFF
SET LINESIZE 10000
SET NEWPAGE NONE
SET TRIMSPOOL ON

Checked http://docs.oracle.com/cd/B19306_01/server.102/b14357/ch12040.htm#i2699283 but don't see an example of doing so.

Upvotes: 3

Views: 768

Answers (1)

Nick Krasnov
Nick Krasnov

Reputation: 27261

Is it possible to set multiple system variables in a single command?

Yes you can. Simply specify variable name/value pairs using space as a delimiter between previous variable's new value and the next variable's name. Here is an example:

/* display variables' current values */
SQL> show colsep echo feedback heading linesize

colsep " "
echo OFF
FEEDBACK ON for 6 or more rows
heading ON
linesize 80

/* Assign new values */
SQL> set colsep "|" echo on echo on feedback off heading off linesize 1000;

/* Make sure changes are in effect */
SQL> show colsep echo feedback heading linesize

colsep "|"
echo ON
feedback OFF
heading OFF
linesize 1000


SQL> spool off;

Note: When number of system variables are more than a few, this approach will drastically reduce readability. So it would be better to dedicate each variable/value pair its own SET command.

Upvotes: 6

Related Questions