Comment on page
heavysql is the client-side SQL console that displays query results for SQL statements you submit to the HeavyDB Server.
heavysql [<database>] [<options>]
<database>is the name of the database to connect to. The default database name is heavyai.
After starting heavysql, you can enter SQL queries or backslash commands from the command line.
The HEAVY.AI server has a default one hour timeout on individual HTTP requests, including those made from heavysql, when using Thrift HTTP transport. If your queries are expected to exceed the timeout, use either the default heavysql TCP transport or increase the timeout using the
If the connection to the server is lost, heavysql automatically attempts to reconnect.
You can use the backslash commands listed in the table below for a variety of tasks beyond SQL queries.
The commands listed below return results based on privileges granted to the current user. For example, the
\dcommand lists only those databases to which the active heavysql user has access privileges.
Unlike SQL statements, backslash commands do not require a terminating semicolon character.
\vcommands 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.
heavysql> \t ^flight.*
SQL query example:
heavysql> SELECT * FROM movies WHERE movieId=260;
260|Star Wars: Episode IV - A New Hope (1977)|Action|Adventure|Sci-Fi
Backslash command example that describes a table:
heavysql> \d movies
CREATE TABLE movies (
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 heavysql. You can use both SQL commands and heavysql commands in your script.
cat script.sql | heavysql -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 heavysql, you get results similar to the following.
$ cat ~/script.sql | ./heavysql -p MyPasswordShhSecret
User heavyai connected to database heavyai
2|Cuddle Time|Romantic Comedy
4|All the Feels|Drama
User heavyai disconnected from database heavyai
Last modified 6mo ago