The Trino command line interface (CLI) provides a terminal-based, interactive shell for running queries and inspecting catalog structures in any Starburst Enterprise platform (SEP) or Starburst Galaxy cluster. The CLI is distributed as an executable JAR file.

Requirements #

The Trino CLI requires Java 8 or newer, installed and available through the PATH defined in your terminal. Run the java --version command to verify that a compatible Java version is installed.

Download and install #

Download the latest Trino CLI as an executable JAR file from the reference documentation. The latest CLI version is recommended, as the CLI is backwards-compatible with older SEP versions.

The JAR file is usable as-is, but for ease-of-use we recommend moving this file to a directory in your shell’s PATH, renaming it, and making it executable. For example, in Linux:

cd /usr/local/bin
cp -p /home/<username>/Download/trino-cli-*-executable.jar .
mv trino-cli-*-executable.jar trino
chmod +x trino

You can run the same commands in macOS by replacing the directory in line two with /Users/<username>/Downloads/trino-cli-*-executable.jar.

Next, to verify that the installation works, run the following command:

trino --version

This command outputs a string with the CLI version you downloaded:

$ trino --version
Trino CLI 360

Connection #

Use the following steps to access your cluster with the Trino CLI client:

  1. Get the necessary connection information for your cluster.

  2. Launch the CLI with the --server option, specifying the host for your cluster. You can specify a custom port by appending :<port number> to the host.

    trino --server=

    If the cluster requires password authentication, the client prompts you for your password. By default the CLI client uses your operating system username to authenticate. You can override this default and specify a custom username with the --user option.

    trino --server= --user=testuser

    On a successful connection, a trino> prompt is displayed indicating that you are currently in a Trino CLI shell.

For more advanced authentication options and additional information, see the Trino CLI reference documentation.

Authentication #

The Trino CLI and SEP support multiple authentication types to ensure all users are authenticated. Starburst Galaxy uses a username and password authentication system that works with your email address as username.

Authorization #

The Trino CLI and SEP support several authorization systems, including built-in access control. Note the specific behavior of the built in access control with the Trino CLI.

Starburst Galaxy supports role-based access control with numerous clients, including the Trino CLI.

Querying #

In the CLI command prompt, you can issue SQL queries against the cluster. You can review all available commands in the CLI shell with the HELP; command.

The following example commands demonstrate some common operations you can do in the client:

  • To see the list of catalogs configured in the cluster, run a SHOW CATALOGS statement:


    See the following example output:

    trino> SHOW CATALOGS;
    (5 rows)
  • To see the available schemas in a catalog, run a SHOW SCHEMAS statement:


    See the following example output:

    trino> SHOW SCHEMAS FROM tpch;
    (10 rows)
  • To specify a catalog and schema for following queries, run a USE statement:

    USE tpch.sf100;

    See the following example output:

    trino> USE tpch.sf100;
  • To see the available tables in a schema, run a SHOW TABLES statement:

    SHOW TABLES FROM tpch.sf100;

    See the following example output:

    trino:sf100> SHOW TABLES;
    (8 rows)
  • To see the structure of a table, run a SHOW COLUMNS statement:

    SHOW COLUMNS FROM tpch.sf100.customer;

    See the following example output:

    trino:sf100> SHOW COLUMNS FROM customer;
       Column   |     Type     | Extra | Comment
     custkey    | bigint       |       |
     name       | varchar(25)  |       |
     address    | varchar(40)  |       |
     nationkey  | bigint       |       |
     phone      | varchar(15)  |       |
     acctbal    | double       |       |
     mktsegment | varchar(10)  |       |
     comment    | varchar(117) |       |
    (8 rows)
  • To run a query, enter it as a complete SQL statement:

    SELECT custkey, name, phone, acctbal FROM tpch.sf100.customer LIMIT 7;

    See the following example output:

    trino:sf100> SELECT custkey, name, phone, acctbal FROM customer LIMIT 7;

As demonstrated in these example commands, the Trino CLI uses supported SQL statements to review and query data sources connected to SEP or Starburst Galaxy.

To exit the CLI shell, run EXIT;:

trino:sf100> EXIT;

Querying outside of the CLI shell #

In addition to launching the Trino CLI and running queries from its shell, you can execute queries directly from your terminal with the --execute option and a query string:

trino --server --execute 'SELECT custkey, name, phone, acctbal FROM tpch.sf100.customer LIMIT 7'

You can also execute SQL script files with the --file option:

trino --server --file 'nations.sql'

This example uses a script, nations.sql, downloaded from the Trino: The Definitive Guide GitHub repository.

Next steps #

This guide explained basic connection instructions and example queries for the Trino CLI client. To learn more about what you can do with the CLI client, see the following resources: