Available in versions: Dev (3.19)

This documentation is for the unreleased development version of jOOQ. Click on the above version links to get this documentation for a supported version of jOOQ.

MATERIALIZED

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

A VIEW can be marked as MATERIALIZED, which means that its data as defined by SELECT * FROM view is stored on disk for faster retrieval, and synchronised with underlying tables either immediately when those tables are changed (similar to an index), or upon request (similar to a cache that is allowed to be stale).

// Create a new view
create.createMaterializedView("authors", "author_id", "first_name", "last_name")
      .as(select(AUTHOR.ID, AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME)
          .from(AUTHOR))
      .execute();

Dialect support

This example using jOOQ:

createMaterializedView("a", "id").as(select(AUTHOR.ID).from(AUTHOR))

Translates to the following dialect specific expressions:

-- BIGQUERY, COCKROACHDB, ORACLE, POSTGRES, REDSHIFT, SNOWFLAKE, SYBASE, TERADATA, YUGABYTEDB
CREATE MATERIALIZED VIEW a(id)
AS
SELECT AUTHOR.ID
FROM AUTHOR

-- ACCESS, ASE, AURORA_MYSQL, AURORA_POSTGRES, DB2, DERBY, DUCKDB, EXASOL, FIREBIRD, H2, HANA, HSQLDB, INFORMIX, MARIADB, 
-- MEMSQL, MYSQL, SQLDATAWAREHOUSE, SQLITE, SQLSERVER, TRINO, VERTICA
/* UNSUPPORTED */

(These are currently generated with jOOQ 3.19, see #10141), or translate your own on our website

References to this page

Feedback

Do you have any feedback about this page? We'd love to hear it!

The jOOQ Logo