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 OR REPLACE SYNONYM

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

Many dialects support a convenient OR REPLACE clause that allows for dropping any pre-existing synonym by the same name in a single statement.

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

Dialect support

This example using jOOQ:

createOrReplaceSynonym("s").for_("t")

Translates to the following dialect specific expressions:

DB2

CREATE OR REPLACE ALIAS s FOR t

H2, Hana, Oracle

CREATE OR REPLACE SYNONYM s FOR t

SQLServer

DROP SYNONYM IF EXISTS s;
CREATE SYNONYM s FOR t

ASE, Access, Aurora MySQL, Aurora Postgres, BigQuery, ClickHouse, CockroachDB, Derby, DuckDB, Exasol, Firebird, HSQLDB, Informix, 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