8

This may seem as weird question:

If i have user called demo with password Pass1234

When connecting to oracle 11g I can run sqlplus like this with password in command line: on DB host:

C:\> sqlplus demo/Pass1234 

Or remote machine

C:\> sqlplus demo/Pass1234@<ip>:1521/orcl 

I can do so without give the password in command line and expose it like this:

C:\> sqlplus demo

Then I get:

SQL*Plus: Release 11.1.0.7.0 bla bla bla
Copyright (c) bla bla bla
Enter password:  

Then I can enter the password manually.

When connecting to Oracle 12c I can connect like this from any machine (with password):

C:\> sqlplus demo/Pass1234@<ip>:1521/pdborcl

My question is: How to connect to Oracle 12c without tnsnames.ora edit and without write the password in the command line?

I also havn't figured out yet if it is possible to connect to Oracle 12c from sqlplus on the DB host machine without give the IP or localhost, and without editing the tnsnames.ora, like I can do in Oracle 11g?

And more thing, can I do so from a remote machine (even to Oracle 11g) without using a full connect?

(means to give user and db connection in command line and password manually, not like use /NOLOG in command and then: SQL> connect demo/Pass1234@<ip>:1521/pdborcl)

Thanks!

3
  • 1
    From blog.oracle48.nl/… : sqlplus username@\"db_machine:1521/db_servicename\"
    – a1ex07
    May 31, 2016 at 18:41
  • nothing you have described has changed with 12c. If you are connecting to a database (any database from any machine other than the one on which the database is running, you have to provide a host name or ip address, the port the listener is using, and a service name known to the listener. That can be via a reference in tnsnames or an EZ-connect format as shown by @a1ex07. The business about what sqlplus prompts for has more to do with what you supply than with '11g' vs '12c'. Did you know you can connect to a 12c db with a 10g client with no special version considerations?
    – EdStevens
    May 31, 2016 at 22:44
  • @EdStevens sqlplus username won't connect me to a user schema on 12c because it located on pdb, it will try to connect me to the core of the default DB, and there is no such as user at the core. in 11g it will connect me to that user on the default DB(there's no core nor pdb, just db). I would call it a difference. sorry if it was not clear from my question.
    – SHR
    May 31, 2016 at 22:58

1 Answer 1

12

This answer based on a1ex07 comment:

given the folowing detailes:

user name: demo
password: Pass1234
ip: 1.2.3.4
listener port: 1521
oracle SID: orcl
pdb service name: pdborcl

connect to core db from db host as sysdba:

  • without need of password: sqlplus / as sysdba
  • password manually: sqlplus sys as sysdba
  • password in command: sqlplus sys/Pass1234 as sysdba

connect to core db from db host or remote as sysdba:

  • password manually: sqlplus sys@\"1.2.3.4:1521/orcl\" as sysdba
  • password in command: sqlplus sys/[email protected]:1521/orcl as sysdba

connect to pdb from db host or remote as sysdba:

  • password manually: sqlplus sys@\"1.2.3.4:1521/pdborcl\" as sysdba
  • password in command: sqlplus sys/[email protected]:1521/pdborcl as sysdba

connect to pdb from db host or remote as demo (regular user):

  • password manually: sqlplus demo@\"1.2.3.4:1521/pdborcl\"
  • password in command: sqlplus demo/[email protected]:1521/pdborcl

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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