oracle-databasecommand-linesqlplusdatabase-link

How do I connect to Oracle database link directly using SQLPLUS


I tried each of the following - none worked:

[oracle@localhost]$ sqlplus system/oracle@SID_NAME

[oracle@localhost]$ sqlplus system/oracle@localhost:1521/SID_NAME

[oracle@localhost]$ sqlplus system/oracle@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=localhost)(Port=1521))(CONNECT_DATA=(SID=SID_NAME)))

[oracle@localhost]$ sqlplus "system/oracle@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=localhost)(Port=1521))(CONNECT_DATA=(SID=SID_NAME)))"

Does SQL*Plus support direct connection to an "Oracle database link" at initial command prompt? If so - how?

SID_NAME does not point to a database but "Oracle database link": https://docs.oracle.com/cd/B28359_01/server.111/b28310/ds_concepts002.htm#i1007709

I am able to query the "Oracle database link" after connection to the local Oracle database. The local Oracle database is where the link has been created and points to the remote database. It connects via an ODBC DSN.

However, I am interested in connecting to the Oracle database link directly at initial sqlplus command prompt.

The local Oracle database port is 1521.

The error message I get:

ERROR: ORA-01017: invalid username/password; logon denied

The whole point is to debug (GDB) an ODBC driver. With isql - at command prompt - I can provide the ODBC DSN and when I run info sharedlibrary at GDB prompt - I can see my loaded library and hence debug. I am interested in getting the driver loaded in the same way using sqlplus. I was unable to see the loaded library post connection. Hence - trying to get the library loaded at initial command just like isql.

At what point does sqlplus actually load the ODBC driver for remote database? I know it does when a query is being executed and unloads it on exit. But I am unable to trap it - even though a breakpoint exists.


Solution

  • SQLPlus talks to a remote database using Oracle DB Link. SQLPlus does not directly make ODBC calls. SQLPlus talks directly to the database. Databases talks to each other via DB Links, in this case, Oracle DB Link through "Oracle Heterogeneous Services (HS)". ODBC driver "never" gets loaded by SQLPlus, thus, there is no way to debug the driver using this method. Also, neither does the database that SQLPlus connects to is loading the ODBC driver. It uses OCI/C code just like SQLPlus does to connect to another database.