Search code examples
oracle-databasesqlplus

sqlplus connection string with a user name in double quotes


I'm wondering how a user with a double quoted name supposed to log in?

create user test_default identified by test_pass;
GRANT CREATE SESSION TO test_default;

sqlplus test_default/test_pass@localhost/DBRAZRAB <-- works fine, I'm connected
create user "test_lowercase" identified by test_pass;
GRANT CREATE SESSION TO "test_lowercase";

sqlplus "test_lowercase"/test_pass@localhost/DBRAZRAB <-- ORA-01017: invalid username/password; logon denied

SQL*Plus: Release 19.0.0.0.0 - Production on Wed Jan 5 12:34:56 2022

Version 19.3.0.0.0

I guess, I should somehow modify the connection string, but how?


Solution

  • You, of course, can do that - only if you know how :)

    Creating user, blabla - it works, as you already know:

    SQL> connect sys as sysdba
    Enter password:
    Connected.
    SQL> create user "test_lowercase" identified by test_pass;
    
    User created.
    
    SQL> grant create session to "test_lowercase";
    
    Grant succeeded.
    
    SQL> connect "test_lowercase"/test_pass
    Connected.
    SQL> exit
    Disconnected from Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
    

    But, can you connect from operating system using sqlplus executable?

    c:\Temp>sqlplus "test_lowercase"/test_pass
    
    SQL*Plus: Release 11.2.0.2.0 Production on Sri Sij 5 20:46:04 2022
    
    Copyright (c) 1982, 2014, Oracle.  All rights reserved.
    
    ERROR:
    ORA-01017: invalid username/password; logon denied
    

    Whoops! That won't work.

    But, if you escape double quotes, then it works:

    c:\Temp>sqlplus \"test_lowercase\"/test_pass
    
    SQL*Plus: Release 11.2.0.2.0 Production on Sri Sij 5 20:46:09 2022
    
    Copyright (c) 1982, 2014, Oracle.  All rights reserved.
    
    
    Connected to:
    Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
    
    SQL>
    

    Ta-daa!