0

I have a script that needs to connect to oracle db hosted on a different server .I am able to connect to this oracle db using sqldeveloper.But i am not able to configured it in my bash script . SQLDEVELOPER 4.0 is the tool that i use to connect through gui .How can i use this in my script .Is there any other way to do it ?Do i need any other software (sqlplus)

deepak pandey
  • 101
  • 3
  • 13
  • Possible duplicate of [How do you execute SQL from within a bash script?](https://stackoverflow.com/questions/1467846/how-do-you-execute-sql-from-within-a-bash-script) – Patrick Bacon May 25 '17 at 19:42

3 Answers3

0

try using following once:

sqlplus db_user_name/password_for_user@DB_schema < Input_file.sql > Output
RavinderSingh13
  • 130,504
  • 14
  • 57
  • 93
0

You need sqlplus to achieve what you're trying to do. The syntax of the command you need to put in you shell script should be like:

sqlplus 'USER/PASSWORD@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=DB_HOST)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=SERVICE_NAME_YOU_USE_IN_SQLDEVELOPER)))' 
0

On *nix systems, this will create a csv stream of results to standard out:

java -Djava.security.egd=file///dev/urandom -jar jdbcsql.jar -d oracledb_SID -h $host -p 1521 -U some_username -m oracle -P "$PW" -f excel -s "," "$1"

Note that adding the -Djava.security.egd=file///dev/urandom increases performance greatly

Windows commands are similar: see http://jdbcsql.sourceforge.net/

Rondo
  • 3,458
  • 28
  • 26