You have:
- an Oracle database
- an Oracle Client installation, including SQL*Plus
- the TNS information for #1
- BUT NO TNSNames.ORA file or the desire to create and maintain one
How can you get your SQL*Plus connection going?
You have:
How can you get your SQL*Plus connection going?
sqlplus user/password@(description=(address_list=(address=.......ODS)))
The text in the () is the information you would see for your service in a TNSNames file. So you can simply use the TNS entry explicitly
Note, use quotes if in Unix else the () are interpreted by the shell.
Or you can use the EZconnect syntax (my preferred method)
sqlplus user/password@//hostname/service_name
sqlplus user/password@//hostname:port/service_name
Note that for Oracle Database 12/18c multitenant architecture databases, you MUST use the /service_name and not the /SID if you want to connect to a pluggable database.
Note also that we have 2 command-line interfaces now.
SQL*Plus and SQLcl.
SQLcl is java based, and a stripped down version of Oracle SQL Developer. It supports TNS based connections, and also supports the EZConnect syntax. One significant advantage it has over SQL*Plus is that it does not require an Oracle Client installation.
This question was originally answered by Tom on AskTom.
I've updated his answer here to address Oracle 12c Multitenant and SQLcl.
Assuming, sqlcl
executable is present in the current directory, you can use
./sql user/password@host:port/service_name
//
after the @
! Many THX @thermz. –
Leverhulme If you don't want to leave password in bash history, use this:
# connect
sql user@host:port/database
# will ask password later
# then connect to your database
sql > conn database
Using a tnsnames.ora
file is just one out of four different naming methods, see Parameters for the sqlnet.ora File
Usually ldap
and nis
are suitable only when you have many Oracle databases running in your premises. Other methods are already provided by @thatjeffsmith
© 2022 - 2024 — McMap. All rights reserved.