How to default to the local database when logging in from the command line

By November 20, 2020Oracle DB
Run another search:
You are here:
< Back

Set the ORACLE_SID via My Computer > Properties > Advanced > Environment Variables. Add a new variable (or edit existing) by clicking New and supplying a variable name of ORACLE_SID and a value of whatever the database (service) name is as it appears in the tnsnames.ora file. Click OK when you are done.

When you log in from the command line again, the new variable will be picked up and you should get something similar to the following:

C:\Documents and Settings\Administrator>sqlplus protect

SQL*Plus: Release 10.2.0.4.0 - Production on Tue Feb 10 13:49:24 2009

Copyright (c) 1982, 2007, Oracle. All Rights Reserved.

Enter password:

Connected to:Oracle Database 10g Release 10.2.0.4.0 - Production

SQL>

To connect to another database, provide the net service name as it appears in the tnsnames.ora file. Use the following example:

C:\Documents and Settings\Administrator>sqlplus protect@vontudbs

SQL*Plus: Release 10.2.0.4.0 - Production on Tue Feb 10 13:49:24 2009

Copyright (c) 1982, 2007, Oracle. All Rights Reserved.

Enter password:

Connected to:Oracle Database 10g Release 10.2.0.4.0 - Production

SQL>

Was this article helpful?
0 out Of 5 Stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
How can we improve this article?