语法:HO[ST] [command]
功能:在SQL*Plus中执行操作系统命令。
如果单独执行host命令,则会进入操作系统提示符界面,这时可以多次执行操作系统命令,再次执行exit命令则会退回到SQL*Plus界面。
与host命令有同样功能的符号为$(windows环境)、!(unix环境)。
SQL> host date
Thu Aug 15 17:39:45 CST 2019
SQL> ! who
root pts/0 2019-08-15 17:13 (1.1.1.1)
SQL> host
[oracle@17:40:34]$ date
Thu Aug 15 17:40:42 CST 2019
[oracle@17:40:42]$ exit
exit
SQL>
Usage
In some operating systems, you can use a character in place of HOST such as "$" in
Windows or "!" in UNIX, or you may not have access to the HOST command. See the
platform-specific Oracle documentation provided for your operating system or ask your
DBA for more information.
On some platforms, an _RC substitution variable may be created with a HOST return
value that is operation system dependent. It is recommended that you do not use the
_RC substitution variable in scripts as it is not portable.
SQL*Plus removes the SQLTERMINATOR (a semicolon by default) before the HOST
command is issued. A workaround for this is to add another SQLTERMINATOR. See
SET SQLT[ERMINATOR] {; | c | ON | OFF} for more information.