Trino Client Supported Features

Prev Next

Creating Database Views

You can create database views using the Trino client when connected to a VAST Database. Views allow you to save queries and re-use them in other queries.

Database views are stored queries that present a part of a VAST Database. They are created and managed using the client application and stored in a table in the database itself. They can be used in other queries on the database.

Action

Example

Create a new View

CREATE VIEW vast."mybucket/myschema".myview
    COMMENT "view comment"
         AS (SELECT col1, col2
               FROM vast."mybucket/myschema".mytable
              WHERE col1 > 0)

List Views in the database

Trino has no direct way of listing views. You can use workarounds like this example, where all views have the suffix "_view".

SHOW TABLES FROM vast."mybucket/myschema" LIKE '%_view%'

Show details for a View

SHOW CREATE VIEW vast."mybucket/myschema".myview

Redefine a View

ALTER VIEW vast."mybucket/myschema".myview
        AS (SELECT col1, col2
              FROM vast."mybucket/myschema".mytable
             WHERE col1 > 0 AND col2 > 0)

Query using a View

  SELECT *
    FROM vast."mybucket/myschema".myview
   WHERE v_col2 > 5
ORDER BY v_col1

Rename a View

ALTER VIEW vast."mybucket/myschema".myview RENAME TO vast."mybucket/myschema".mynewview

Limitations

  • View properties are not supported

  • Nested data types are not supported

  • User-defined column names and comments are lost if the schema of the query changes when redefining a view