Sqlplus oracle : How can I run sql command on bash in 1 line?

本秂侑毒 提交于 2020-01-14 07:20:14

问题


Can I convert this into 1 command line on bash in sqlplus? cause i want to automate it.

sqlplus / as sysdba
SQL> EXEC DBMS_XDB.SETLISTENERLOCALACCESS(FALSE);
exit

回答1:


You won't need the exit with automation because it should exit on end of file anyway. So on one line you could do:

echo 'EXEC DBMS_XDB.SETLISTENERLOCALACCESS(FALSE);' | sqlplus / as sysdba



回答2:


sqlplus user/password@host @file.sql



回答3:


you can wirite by follow in a shell

#!/bin/bash
sqlplus / as sysdba <<EOF
EXEC DBMS_XDB.SETLISTENERLOCALACCESS(FALSE);
exit
EOF

or you can put this commond into a procedure




回答4:


sqlplus /nolog @your_script.sql



来源:https://stackoverflow.com/questions/11237824/sqlplus-oracle-how-can-i-run-sql-command-on-bash-in-1-line

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!