I can connect to remote Oracle DB using this signature:
sqlplus 'user/pass@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=hostname.network)(Port=1521))(CONNECT_DATA=(SID=remote_SID)))'
Now want to execute a script and save results to local CSV file – how to do that?
I already have a script that is doing a work but need a terminal (bash) command to connect (remotely) to a DB and then call a script (all in 1 command).
Guessing something like this (but did not work):
sqlplus 'user/pass@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=hostname.network)(Port=1521))(CONNECT_DATA=(SID=remote_SID)))' @sql_script
Thanks.
Best Answer
SQL*Plus starting with version 12.2 supports printing the output in CSV format.
You can add the below in your script:
Then execute your script called
myscript.sql
as:For example: