Available in versions: Dev (3.20) | Latest (3.19) | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11 | 3.10

SQL Statements (DDL)

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

The Data Definition Language (DDL) is used to CREATE, ALTER, and DROP various object types in the database catalog. jOOQ supports an increasing number of these operations natively, and also adds synthetic operation support for convenience.

While many DDL statements are supported natively, and have a 1:1 correspondence to the jOOQ API's representation, dialects differ in many subtle ways when it comes to DDL statement support. These differences may include:

  • Different keywords to mean the same thing. For example, the keywords ALTER, CHANGE, or MODIFY may be used when altering columns or other attributes in a table.
  • Different statements instead of subclauses. For example, some dialects may choose to support RENAME [object type] .. TO .. statements instead of making the rename operation a subclause of ALTER [object type] .. RENAME TO ..
  • Some syntax may not be supported, or not be supported consistently, such as the various IF EXISTS and IF NOT EXISTS clauses. Emulations are possible using the dialect's procedural language

Because of these many differences, the jOOQ manual will not list each individual native SQL representation of each jOOQ API call. Also, some optional clauses may exist, such as the IF EXISTS or OR REPLACE clauses, which can easily be discovered from the API. The manual will omit documenting these clauses in every example.

Commercial support for emulations

A lot of DDL queries come with syntax that requires emulation using anonymous blocks. While basic anonymous blocks are supported in the jOOQ Open Source Edition as well, more sophisticated blocks and other procedural logic is a commercial only feature.

Table of contents

4.6.1.
The ALTER statement
4.6.1.1.
ALTER DATABASE
4.6.1.2.
ALTER DOMAIN
4.6.1.3.
ALTER INDEX
4.6.1.4.
ALTER SCHEMA
4.6.1.5.
ALTER SEQUENCE
4.6.1.6.
ALTER TABLE
4.6.1.7.
ALTER TYPE
4.6.1.7.1.
ALTER TYPE .. RENAME
4.6.1.7.2.
ALTER TYPE .. for enum alterations
4.6.1.8.
ALTER VIEW
4.6.1.8.1.
ALTER VIEW .. COMMENT
4.6.1.8.2.
ALTER VIEW .. RENAME
4.6.1.8.3.
ALTER VIEW IF EXISTS
4.6.2.
The COMMENT statement
4.6.2.1.
COMMENT ON TABLE
4.6.2.2.
COMMENT ON VIEW
4.6.2.3.
COMMENT ON COLUMN
4.6.3.
The CREATE statement
4.6.3.1.
CREATE DATABASE
4.6.3.2.
CREATE DOMAIN
4.6.3.3.
CREATE FUNCTION
4.6.3.3.1.
Scalar functions
4.6.3.3.2.
CREATE OR REPLACE FUNCTION
4.6.3.3.3.
SQL data access characteristics
4.6.3.3.4.
DETERMINISTIC characteristic
4.6.3.3.5.
ON NULL INPUT characteristic
4.6.3.4.
CREATE INDEX
4.6.3.5.
CREATE PROCEDURE
4.6.3.5.1.
CREATE OR REPLACE PROCEDURE
4.6.3.5.2.
SQL data access characteristics
4.6.3.6.
CREATE SCHEMA
4.6.3.7.
CREATE SEQUENCE
4.6.3.7.1.
CREATE SEQUENCE IF NOT EXISTS
4.6.3.7.2.
CREATE SEQUENCE .. CACHE
4.6.3.7.3.
CREATE SEQUENCE .. CYCLE
4.6.3.7.4.
CREATE SEQUENCE .. MINVALUE
4.6.3.7.5.
CREATE SEQUENCE .. MAXVALUE
4.6.3.7.6.
CREATE SEQUENCE .. INCREMENT BY
4.6.3.7.7.
CREATE SEQUENCE .. START WITH
4.6.3.8.
CREATE TABLE
4.6.3.8.1.
Columns
4.6.3.8.2.
Nullability
4.6.3.8.3.
Defaults
4.6.3.8.4.
Identities
4.6.3.8.5.
Computed columns (new)
4.6.3.8.6.
Primary key
4.6.3.8.7.
Unique constraints
4.6.3.8.8.
Foreign keys
4.6.3.8.9.
Check constraints
4.6.3.8.10.
From a SELECT
4.6.3.8.11.
Temporary tables
4.6.3.9.
CREATE TRIGGER
4.6.3.9.1.
Events
4.6.3.9.2.
REFERENCING clause
4.6.3.9.3.
STATEMENT vs ROW triggers
4.6.3.9.4.
WHEN clause
4.6.3.10.
CREATE TYPE
4.6.3.11.
CREATE VIEW
4.6.3.11.1.
OR REPLACE
4.6.3.11.2.
WITH CHECK OPTION
4.6.3.11.3.
WITH READ ONLY
4.6.4.
The DROP statement
4.6.4.1.
DROP DATABASE
4.6.4.1.1.
DROP DATABASE IF EXISTS
4.6.4.2.
DROP DOMAIN
4.6.4.2.1.
DROP DOMAIN IF EXISTS
4.6.4.3.
DROP FUNCTION
4.6.4.3.1.
DROP FUNCTION IF EXISTS
4.6.4.4.
DROP INDEX
4.6.4.4.1.
DROP INDEX IF EXISTS
4.6.4.5.
DROP PROCEDURE
4.6.4.5.1.
DROP PROCEDURE IF EXISTS
4.6.4.6.
DROP SCHEMA
4.6.4.6.1.
DROP SCHEMA IF EXISTS
4.6.4.7.
DROP SEQUENCE
4.6.4.7.1.
DROP SEQUENCE IF EXISTS
4.6.4.8.
DROP TABLE
4.6.4.8.1.
DROP TABLE IF EXISTS
4.6.4.9.
DROP TRIGGER
4.6.4.9.1.
DROP TRIGGER IF EXISTS
4.6.4.10.
DROP TYPE
4.6.4.10.1.
DROP TYPE IF EXISTS
4.6.4.11.
DROP VIEW
4.6.4.11.1.
DROP VIEW IF EXISTS
4.6.5.
The GRANT statement
4.6.6.
The REVOKE statement
4.6.7.
The SET statement
4.6.7.1.
SET CATALOG
4.6.7.2.
SET SCHEMA
4.6.8.
The TRUNCATE statement
4.6.9.
Generating DDL from objects

previous : next

Feedback

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

The jOOQ Logo