SQL Plus - Host

> Procedural Languages > (SQL Plus|SqlCl) (Oracle Database Console)

1 - About

Host executes an operating system command without leaving SQL*Plus.

Enter HOST without command to display an operating system prompt and EXIT to return.

Advertising

3 - Syntax

HO[ST] [command]

On Unix system, you can use the Exclamation mark as alias.

4 - Child process

The host command starts a child process. It has therefore no influence on the working directory of SQLPlus.

  • Just don't stay in your OS home directory
cd C:\temp
  • start SQLPlus
sqlplus myLogin/MyPasswor@MyTnsNames
  • and execute this command:
host dir

It will give your OS home directory and not your current working directory:

 Volume in drive C has no label.
 Volume Serial Number is AEB0-A348

 Directory of C:\users\gerard

2013-10-15  17:08    <DIR>          .
2013-10-15  17:08    <DIR>          ..
2012-10-16  13:45    <DIR>          .ant
2013-06-06  12:58               498 .dbfit.jks
2012-09-16  19:25    <DIR>          .eclipse
2013-08-31  12:27               182 .gitconfig
2013-03-08  11:39    <DIR>          .hudson
2013-05-01  11:10    <DIR>          .idlerc
2012-11-10  16:37    <DIR>          .jmsn
2012-10-16  13:45    <DIR>          .m2
2013-05-01  09:33    <DIR>          .ssh
2013-05-16  09:20    <DIR>          .VirtualBox
2012-09-20  21:45    <DIR>          .zenmap
2012-05-11  08:24    <DIR>          AppData
2012-06-22  12:04    <DIR>          catalogmanager
2013-01-22  19:01             3,664 COBI_UTILS_PCK.sql
2013-01-22  19:01            82,132 COBI_UTILS_PCK_1.sql
2013-01-22  19:05             3,400 COBI_UTILS_PCK_2.sql
2013-01-23  11:15            80,439 COBI_UTILS_PCK_3.sql
2013-01-22  19:06            77,039 COBI_UTILS_PCK_4.sql
2013-09-20  10:02    <DIR>          Contacts
2012-06-01  15:29             1,577 data_template.xml
2013-10-28  14:57               562 default-soapui-workspace.xm
...........................................

5 - Example

5.1 - Windows

host dir
 Volume in drive D is Yo
 Volume Serial Number is 52EE-02AA

 Directory of D:\temp\

2013-10-14  17:55    <DIR>          .
2013-10-14  17:55    <DIR>          ..
2013-09-12  15:37               204 myFile.txt
2013-10-14  17:48               655 myDemo.bat
...................................................
...................................................
              13 File(s)         14,866 bytes
               2 Dir(s)  78,909,874,176 bytes free
Advertising

5.2 - Linux

!pwd
/home/oracle
lang/sqlplus/host.txt · Last modified: 2017/05/09 16:51 by gerardnico