Search code examples
oracle-databasespecial-characterssqlplus

SQLPLUS Connection to DB with special characters '@'


I'm trying to connect to my remote db with a user who has an @ in his password.

I use sqlplus v19 with an OracleClient and my remote db is an OracleServer v19 aswell. I had no problem during the alter user command on the database :

alter user USER identified by "P@ssword123";
user altered.

Below are the commands I tried to connect with this user :

sqlplus USER/"P@ssword123"@tnsname
sqlplus USER/'"P@ssword123"'@tnsname
sqlplus 'USER/"P@ssword123"'@tnsname
sqlplus USER/\"P@ssword123\"@tnsname

And some variants of those commands. This always return me the same TNS error :
TNS:could not resolve the connect identifier specified

It looks like these solutions works for old sqlplus versions but I can't figure out how can I solve my problem with this version 19.

Of course, I tried to change the password with non @ character and it works but this is not a possible solution in my specific case.


Solution

  • Thank you for all your replies.
    I figure it out with your help. I even modified it to make it compatible with a PL/SQL Script which I pass some variables.
    The answer :

    sqlplus /NOLOG << EOF
    connect USER/"P@ssword123"@tnsname
    @script_plsql.sql $var1 $var2 $var3
    EOF