 |
|
Connecting to SQL*Plus
Oracle Tips by
Burleson
|
You’ll probably connect to SQL*Plus using a command like:
sqlplus username/password
SQL*Plus provides some alternative methods of connecting that you
should be aware of. For instance:
sqlplus [-silent] username/password
Logging into SQL*Plus using the -silent flag instructs the
program not to give any informational messages (not even a prompt).
This is particularly useful when your script is dynamically generating
code or when executing SQL*Plus from inside another piece of software.
If you login and find that you need to be working under another
schema, you can login to a new schema without exiting SQL*Plus and
reconnecting by using the following command:
connect username/password
You can use any of these login commands without typing your
username or password as part of the command; SQL*Plus will prompt you
for these values if you don’t include them in the command. Using your
password as part of a command reveals the password to anyone who sees
the command, so it’s probably better to enter your password when
prompted in most situations.
Logging Out Of SQL*Plus
The exit and quit commands are used to leave SQL*Plus
and return to the operating system. You should be aware that using
either of these commands implicitly commits changes to the database.
If you’ve made changes that you don’t want to save, you’ll have to
roll back prior to issuing one of these commands.
You can use this command to return a status to an OS-level
application that called the script, as shown in the following example:
exit success
There are five values that can be returned: success,
failure, warning, integer, and variable.
- success—The script ended execution
normally. The value of this status depends on the host operating
system.
- failure—The script failed at some
point. The value of this status depends on the host operating
system.
- warning—The script exited in a warning
state. The value of this status depends on the host operating
system.
- integer—You can return specific integer
values that suit your needs.
- variable—You can return the contents of
a variable as the status. This variable does not have to be an
integer or number variable.
This is an excerpt from the book "High Performance Oracle
Database Automation" by Jonathan Ingram and Donald K.
Burleson, Series Editor. |