Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLPlus: using special character for password in script

Tags:

sqlplus

I have issue with special character in password - '@'. Issue that i don't know how to pass password with this special character to script file and connect using sqlplus.

For example i have user 'test_user' with password 'temp123@'. For login via sqlplus i use following string with escaping: sqlplus test_user/\"temp123@\"@some-db:1521/SID

It's works well. For my case i need to pass password as parameter for sql script. For example, i have following script to connect (actually script using several pairs of login/password to update many users at once):

-- @deploy.sql
connect &&2./&&3.@&&1.

At have failure with that because password with '@' can't interpreted correctly by sqlplus. I tried many advices from google with escaping but mostly of them applicable for connect string at sqlplus invoke. For my case its required for parameter that passed to script.

like image 650
Torsten Avatar asked Jul 28 '14 08:07

Torsten


People also ask

Can Oracle password have special characters?

Passwords can contain only alphanumeric characters and the underscore (_), dollar sign ($), and pound sign (#). Password may NOT contain the "@" character. However, Oracle strongly discourages you from using $ and #.

How do you pass special characters in Oracle query?

Answer: Oracle handles special characters with the ESCAPE clause, and the most common ESCAPE is for the wildcard percent sign (%), and the underscore (_). For handling quotes within a character query, you must add two quotes for each one that is desired.

How do I pass a password with a special character in PowerShell script?

For example, if the password contains a dollar sign ($) it must either be preceded by a grave accent ` (also known as a backtick: ASCII code 96 - Alt+96) or the password encapsulated in single ' ' to pass the password to PowerShell exactly as entered.


1 Answers

use : cmd.exe and not powershell window

if not : 

in powershell windows : sqlplus 'login/\"P@$$w0rd\"@TNS_NAME'

in cmde.exe : sqlplus login/\"P@$$w0rd\"@TNS_NAME

like image 174
mouhcine Avatar answered Nov 07 '22 20:11

mouhcine