omnisql
Synopsis
omnisql [<database>]
[{--user|-u} <user>]
[{--passwd|-p} <password>]
[--port <port number>]
[{-s|--server} <server host>]
[--http]
Description
omnisql
is the client-side SQL console that displays query results for SQL statements you submit
to the OmniSci Core Server.
Options
Running omnisql
After starting omnisql
, you can enter SQL queries or backslash commands from the command line.
The OmniSci server has a default one hour timeout on individual HTTP requests, including those made from omnisql
, when using Thrift HTTP transport. If your queries are expected to exceed the timeout, use either the default omnisql
TCP transport or increase the timeout using the omnisci_web_server
--timeout
option.
If the connection to the server is lost, omnisql
automatically attempts to reconnect.
Commands
You can use the backslash commands listed in the table below for a variety of tasks beyond SQL queries.
Note | The commands listed below return results based on privileges granted to the current user. For example, the \d command lists only those databases to which the active omnisql user has access privileges. |
Unlike SQL statements, backslash commands do not require a terminating semicolon character.
Runtime Examples
The \t
, \u
, and \v
commands might return a long list of values. You can use a regular expression match pattern to filter the results. For example, you could use the following command to return only tables that start with the word flight.
omnisql> \t ^flight.*
flights_2008_10k
flights_2008_7M
SQL query example:
omnisql> SELECT * FROM movies WHERE movieId=260;
movieId|title|genres
260|Star Wars: Episode IV - A New Hope (1977)|Action|Adventure|Sci-Fi
Backslash command example that describes a table:
omnisql> \d movies
CREATE TABLE movies (
movieId INTEGER,
title TEXT ENCODING DICT(32),
genres TEXT ENCODING DICT(32))
If you frequently perform the same tasks, you can create a script and pipe it to omnisql
. You can use both SQL commands and omnisql commands in your script.
cat script.sql | omnisql -p <password>
For example, if you periodically upload data to the movies table, you can append rows from files named movies.csv using the following script, and display the results.
\copy ./movies.csv movies
select * movies;
When you pipe the script to omnisql, you get results similar to the following.
$ cat ~/script.sql | ./omnisql -p MyPasswordShhSecret
User omnisci connected to database omnisci
movieId|title|genres
1|Explosions Extravaganza|Action
2|Cuddle Time|Romantic Comedy
3|Chuckle Buddies|Comedy
4|All the Feels|Drama
User omnisci disconnected from database omnisci