Sqlplus oracle:如何在 bash 的 1 行中运行 sql 命令?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11237824/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Sqlplus oracle : How can I run sql command on bash in 1 line?
提问by Kit Ho
Can I convert this into 1 command line on bash in sqlplus? cause i want to automate it.
我可以在 sqlplus 中的 bash 上将其转换为 1 个命令行吗?因为我想自动化它。
sqlplus / as sysdba
SQL> EXEC DBMS_XDB.SETLISTENERLOCALACCESS(FALSE);
exit
回答by Sodved
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
回答by Neerav
sqlplus user/password@host @file.sql
回答by Jie Hou
you can wirite by follow in a shell
您可以通过在 shell 中跟随来编写
#!/bin/bash
sqlplus / as sysdba <<EOF
EXEC DBMS_XDB.SETLISTENERLOCALACCESS(FALSE);
exit
EOF
or you can put this commond into a procedure
或者你可以把这个共同点放到一个程序中
回答by I?ja
sqlplus /nolog @your_script.sql
sqlplus /nolog @your_script.sql