Available in versions: Dev (3.20)

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.

CREATE SYNONYM

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

A SYNONYM or ALIAS is an alternative name for an object, mostly a TABLE or VIEW, which can be used just like the actual name in any SQL statement. With a synonym S_BOOK for the table BOOK, for example, you can write the following query:

SELECT s_book.id FROM s_book

To create the synonym, write

create.createSynonym("s").for_("t").execute();

To create a PUBLIC synonym, i.e. a synonym that doesn't belong to any schema or owner, write

create.createPublicSynonym("s").for_("t").execute();

Dialect support

This example using jOOQ:

createSynonym("s").for_("t")

Translates to the following dialect specific expressions:

DB2

CREATE ALIAS s FOR t

Derby, H2, HSQLDB, Hana, Informix, Oracle, SQLServer

CREATE SYNONYM s FOR t

ASE, Access, Aurora MySQL, Aurora Postgres, BigQuery, ClickHouse, CockroachDB, DuckDB, Exasol, Firebird, MariaDB, MemSQL, MySQL, Postgres, Redshift, SQLDataWarehouse, SQLite, Snowflake, Sybase, Teradata, Trino, Vertica, YugabyteDB

/* UNSUPPORTED */
Generated with jOOQ 3.20. Translate your own SQL on our website

Feedback

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

The jOOQ Logo