5. Connecting to the Installation : Using the Terminal Monitor (sql)
Share this page                  
Using the Terminal Monitor (sql)
The Terminal Monitor is a command line tool for interacting with the database that is useful for using in scripts or when using a graphical interface is not possible.
The behavior of the Terminal Monitor is controlled by command line switches on the sql command (described in the User Guide).
Note:  By default, autocommit is turned off in the Terminal Monitor. Your statements are not committed until you issue a COMMIT statement or until you log out of the Terminal Monitor.
To connect to the database using the Terminal Monitor specify the database name and, if the database is running remotely, vnode information (see Connecting to a Remote Server) that defines how to connect to the instance. For example:
Connect to the local database testdb:
sql testdb
Connect to remote database using static vnode:
sql myvnode::pocdb
Connect to remote database using dynamic vnode:
sql @host1,tcp_ip,VH;[actian,actian]::pocdb
Useful command line switches include:
-uusername - Specifies user name for the session
‑Ppassword - Specifies the password for user
‑S - Runs silently, only shows results
Useful commands include:
Invokes an editor to modify the contents of the query buffer.
Executes the current contents of the query buffer.
Prints the current contents of the query buffer.
\read file
Reads the contents of file into the query buffer.
Clears the query buffer.
Includes query timings in the output.
Removes space padding from the output.
Lists objects in the database (see below). To see the syntax of the HELP statement, type HELP HELP.
In addition, the Terminal Monitor can also use redirected input and output with the "<" and ">"characters (for example, sql pocdb < poc.sql). reads the commands in the poc.sql file. The file must contain all terminal monitor commands needed to run the session.
Commands in the Terminal Monitor are separated by ";".
[actian@VectorH-HW1 ~]$ sql pocdb
TERMINAL MONITOR Copyright 2014 Actian Corporation
Actian Vector H Linux Version VH 4.1.1 (a64.lnx/158) login
Thu Jun 18 10:38:38 2015
Enter \g to execute commands, "help help\g" for general help,
"help tm\g" for terminal monitor help, \q to quit
* create table mytab (col1 int);
* insert into mytab values (1);
* \g
Executing . . .
(1 row)
* help \g
Executing . . .
Name Owner Type
mytab actian table
(1 row)
* help table mytab; \g
Executing . . .
Name: mytab
Owner: actian
Created: 18-jun-2015 10:39:05
Location: ii_hdfsdata