Page 1 of 1

Oracle SQL*Plus HOST command

Posted: Fri Apr 03, 2015 11:29 am
by Josh
Hi,

In Oracle SQL*Plus there is a HOST command that can be used to display the operating system prompt. From there I can enter operating system commands which do not effect my SQL*Plus session which stays connected to the DB. There doesn't seem to be a HOST command in vsql. Anyone know if there is a work around?

Re: Oracle SQL*Plus HOST command

Posted: Fri Apr 03, 2015 11:41 am
by JimKnicely
Hi,

In vsql you can use the \! meta-command all by itself to temporarily leave vsql.

The example below will show you that the vsql session is unaffected:

Code: Select all

dbadmin=> create table t (c int);
CREATE TABLE

dbadmin=> insert into t values (1);
 OUTPUT
--------
      1
(1 row)

dbadmin=> select current_session(), * from t;
         current_session          | c
----------------------------------+---
 vertica01.avnet.com-6565:0x7b2a5 | 1
(1 row)
I did not commit the data.

In vsql use the meta-command \! to leave vsql, and then type "exit" at the OS prompt to get back into vsql:

Code: Select all

dbadmin=> \!
[dbadmin@vertica01 ~]$ exit
exit
Back in vsql, the session id remains the same and the T table still has the uncommitted data:

Code: Select all

dbadmin=> select current_session(), * from t;
         current_session          | c
----------------------------------+---
 vertica01.avnet.com-6565:0x7b2a5 | 1
(1 row)

dbadmin=> rollback;
ROLLBACK
dbadmin=> select * from t;
 c
---
(0 rows)

Re: Oracle SQL*Plus HOST command

Posted: Fri Apr 03, 2015 2:16 pm
by Josh
Thanks, Jim!!! Great example, too.