EZconnect for SQL*Plus

Posted by

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

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: ******

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

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



  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?

Got some thoughts? Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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