I am a newbie of SQL*Plus and Oracle, and I have 2 questions about them.

(1) Executing "sqlplus / as sysdba" command:

$ sqlplus / as sysdba

SQL*Plus: Release Production on Thu Feb 18 05:09:38 2016

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Connected to:
Oracle Database 12c Enterprise Edition Release - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options


Does the sqlplus connect an Oracle Instance now?

(2) When use sqlplus connect the local Oracle Instance, like this:

$ sqlplus username/password

Should we also consider sqlplus as a client? If it is true, does the sqlplus also read tnsnames.ora file? And the requests also forward to listener process?

  • Err, yeah. Of course it is. It's THE client. SQL*Plus (and svrmrgl) existed long before any of the modern GUIs. Bit of an odd question, to be honest. Though I'll admit that doing a 'conn / as sysdba' is different to connecting 'normally'. If you're bored, you can truss/strace the process to see what files it reads & what sockets it opens (listener is usually 1521) – Philᵀᴹ Feb 18 '16 at 10:39
  • Don't login as SYS ( / as SYSDBA) unless you're going to shutdown the database – thatjeffsmith Feb 18 '16 at 15:14
  • The use of 'username/password' vs '/ as sysdba' has nothing to do with connecting to a local instance vs. a remote instance. The key to that is the use of "@mydb" in the connect string - with the caveat about the TWO_TASK variable (if linux) or the LOCAL variable (if Windows). In any event, just to be pedantic, sqlplus (nor any other client application) actually reads the tnsnames file. It simply passes the request to the Oracle net layer, which takes care of all routing issues, including resolving a net service name (tnsnames entry) into an actual ip address and listener port number. – EdStevens Feb 18 '16 at 22:47

SQL*Plus is a client that is already available for a very long time. If you use sqlplus username/password then it does not use the tnsnames.ora. It connects to the local database that is defined in the ORACLE_SID environment variable. If you use sqlplus username/password@SID then it will search in the tnsnames.ora file to find out the location of the SID database.

  • 2
    Not quite right, in that if TWO_TASK=REMOTE_SID is set, it does use tnsnames.ora as if sqlplus user/pass@REMOTE_SID was called. – REW Feb 18 '16 at 17:41

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.