Just a quick tip to solve a common issue that is catching people out.

The EZconnect syntax is a great way of connecting to the database without all the rigmarole of setting up and maintaining a tnsnames.ora file. You just nominate the host, service, and optionally the port and away you go.


SQL> connect scott/tiger@//localhost:1519/pdb1
Connected.

Of course, we don’t want to be providing the password on the command line so what happens in SQL*Plus when we leave it out?


SQL> connect scott@//localhost:1519/pdb1
SP2-0306: Invalid option.
Usage: CONN[ECT] [{logon|/|proxy} [AS {SYSDBA|SYSOPER|SYSASM|SYSBACKUP|SYSDG|SYSKM|SYSRAC}] [edition=value]]
where  ::= [/][@]
       ::= [][/][@]

There’s an easy fix though. Just add some quotes and you’re good to go!


SQL> connect scott@'//localhost:1519/pdb1'
Enter password: ******
Connected.

This seems to be a SQL*Plus oddity. SQLcl handles this just fine.


SQL> show version
Oracle SQLDeveloper Command-Line (SQLcl) version: 21.2.2.0 build: 21.2.2.223.0914
SQL> connect scott@//localhost:1519/pdb1
Password? (**********?) *****
Connected.

Enjoy!

2 responses to “EZconnect for SQL*Plus”

  1. When EZCONNECT is in silent.Ora before TNSALIAS (for example in XE containers) using „sqlplus sys@XEPDB1“ becomes painfully slow. So far that specifying @(DESCRIPTOR…) feels fast. Is there a syntax to tell ezconnect to not try to resolve it? Any reason why TNSALIAS method is not first?

    1. Can you elaborate a bit on that with an example? I assume silent.ora is sqlnet.ora 🙂

Got some thoughts? Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Trending