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
, orMODIFY
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 ofALTER [object type] .. RENAME TO ..
- Some syntax may not be supported, or not be supported consistently, such as the various
IF EXISTS
andIF 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
- 3.4.1.
- The ALTER statement
- 3.4.1.1.
- ALTER INDEX
- 3.4.1.1.1.
- ALTER INDEX .. RENAME
- 3.4.1.1.2.
- ALTER INDEX IF EXISTS
- 3.4.1.2.
- ALTER SCHEMA
- 3.4.1.2.1.
- ALTER SCHEMA .. RENAME
- 3.4.1.2.2.
- ALTER SCHEMA IF EXISTS
- 3.4.1.3.
- ALTER SEQUENCE
- 3.4.1.3.1.
- ALTER SEQUENCE .. RENAME
- 3.4.1.3.2.
- ALTER SEQUENCE .. CACHE (new)
- 3.4.1.3.3.
- ALTER SEQUENCE .. CYCLE (new)
- 3.4.1.3.4.
- ALTER SEQUENCE .. MINVALUE (new)
- 3.4.1.3.5.
- ALTER SEQUENCE .. t reaches its MAXVALUE (new)
- 3.4.1.3.6.
- ALTER SEQUENCE .. INCREMENT BY (new)
- 3.4.1.3.7.
- ALTER SEQUENCE .. START WITH (new)
- 3.4.1.3.8.
- ALTER SEQUENCE .. RESTART
- 3.4.1.3.9.
- ALTER SEQUENCE IF EXISTS
- 3.4.1.4.
- ALTER TABLE
- 3.4.1.4.1.
- ALTER TABLE .. ADD COLUMN
- 3.4.1.4.2.
- ALTER TABLE .. ADD COLUMN .. FIRST, BEFORE, AFTER (new)
- 3.4.1.4.3.
- ALTER TABLE .. ADD COLUMNS
- 3.4.1.4.4.
- ALTER TABLE .. ADD COLUMN IF NOT EXISTS
- 3.4.1.4.5.
- ALTER TABLE .. ADD PRIMARY KEY
- 3.4.1.4.6.
- ALTER TABLE .. ADD UNIQUE
- 3.4.1.4.7.
- ALTER TABLE .. ADD FOREIGN KEY
- 3.4.1.4.8.
- ALTER TABLE .. ADD CHECK
- 3.4.1.4.9.
- ALTER TABLE .. RENAME
- 3.4.1.4.10.
- ALTER TABLE .. COMMENT
- 3.4.1.4.11.
- ALTER TABLE .. ALTER COLUMN .. SET DEFAULT
- 3.4.1.4.12.
- ALTER TABLE .. ALTER COLUMN .. DROP DEFAULT (new)
- 3.4.1.4.13.
- ALTER TABLE .. ALTER COLUMN .. SET NOT NULL
- 3.4.1.4.14.
- ALTER TABLE .. ALTER COLUMN .. DROP NOT NULL
- 3.4.1.4.15.
- ALTER TABLE .. ALTER COLUMN .. SET TYPE
- 3.4.1.4.16.
- ALTER TABLE .. ALTER CONSTRAINT .. ENFORCED (new)
- 3.4.1.4.17.
- ALTER TABLE .. ALTER CONSTRAINT .. NOT ENFORCED (new)
- 3.4.1.4.18.
- ALTER TABLE .. RENAME COLUMN
- 3.4.1.4.19.
- ALTER TABLE .. RENAME CONSTRAINT
- 3.4.1.4.20.
- ALTER TABLE .. RENAME INDEX
- 3.4.1.4.21.
- ALTER TABLE .. DROP COLUMN
- 3.4.1.4.22.
- ALTER TABLE .. DROP COLUMN RESTRICT
- 3.4.1.4.23.
- ALTER TABLE .. DROP COLUMN CASCADE
- 3.4.1.4.24.
- ALTER TABLE .. DROP COLUMNS
- 3.4.1.4.25.
- ALTER TABLE .. ADD COLUMN IF NOT EXISTS
- 3.4.1.4.26.
- ALTER TABLE .. DROP CONSTRAINT
- 3.4.1.4.27.
- ALTER TABLE .. DROP PRIMARY KEY
- 3.4.1.4.28.
- ALTER TABLE .. DROP UNIQUE (new)
- 3.4.1.4.29.
- ALTER TABLE .. DROP FOREIGN KEY
- 3.4.1.4.30.
- ALTER TABLE .. DROP CONSTRAINT IF EXISTS (new)
- 3.4.1.4.31.
- ALTER TABLE IF EXISTS
- 3.4.1.5.
- ALTER TYPE (new)
- 3.4.1.5.1.
- ALTER TYPE .. RENAME (new)
- 3.4.1.5.2.
- ALTER TYPE .. for enum alterations (new)
- 3.4.1.6.
- ALTER VIEW
- 3.4.1.6.1.
- ALTER VIEW .. COMMENT
- 3.4.1.6.2.
- ALTER VIEW .. RENAME
- 3.4.1.6.3.
- ALTER VIEW IF EXISTS
- 3.4.2.
- The COMMENT statement
- 3.4.2.1.
- COMMENT ON TABLE
- 3.4.2.2.
- COMMENT ON VIEW
- 3.4.2.3.
- COMMENT ON COLUMN
- 3.4.3.
- The CREATE statement
- 3.4.3.1.
- CREATE INDEX
- 3.4.3.2.
- CREATE SCHEMA
- 3.4.3.3.
- CREATE SEQUENCE
- 3.4.3.3.1.
- CREATE SEQUENCE IF NOT EXISTS
- 3.4.3.3.2.
- CREATE SEQUENCE .. CACHE (new)
- 3.4.3.3.3.
- CREATE SEQUENCE .. CYCLE (new)
- 3.4.3.3.4.
- CREATE SEQUENCE .. MINVALUE (new)
- 3.4.3.3.5.
- CREATE SEQUENCE .. MAXVALUE (new)
- 3.4.3.3.6.
- CREATE SEQUENCE .. INCREMENT BY (new)
- 3.4.3.3.7.
- CREATE SEQUENCE .. START WITH (new)
- 3.4.3.4.
- CREATE TABLE
- 3.4.3.4.1.
- Columns
- 3.4.3.4.2.
- Nullability
- 3.4.3.4.3.
- Defaults
- 3.4.3.4.4.
- Identities
- 3.4.3.4.5.
- Primary key
- 3.4.3.4.6.
- Unique constraints
- 3.4.3.4.7.
- Foreign keys
- 3.4.3.4.8.
- Check constraints
- 3.4.3.4.9.
- From a SELECT
- 3.4.3.4.10.
- Temporary tables
- 3.4.3.5.
- CREATE TYPE
- 3.4.3.6.
- CREATE VIEW
- 3.4.3.6.1.
- CREATE OR REPLACE VIEW
- 3.4.3.6.2.
- WITH CHECK OPTION
- 3.4.3.6.3.
- WITH READ ONLY
- 3.4.4.
- The DROP statement
- 3.4.4.1.
- DROP INDEX
- 3.4.4.1.1.
- DROP INDEX IF EXISTS
- 3.4.4.2.
- DROP SCHEMA
- 3.4.4.2.1.
- DROP SCHEMA IF EXISTS
- 3.4.4.3.
- DROP SEQUENCE
- 3.4.4.3.1.
- DROP SEQUENCE IF EXISTS
- 3.4.4.4.
- DROP TABLE
- 3.4.4.4.1.
- DROP TABLE IF EXISTS
- 3.4.4.5.
- DROP TYPE
- 3.4.4.5.1.
- DROP TYPE IF EXISTS
- 3.4.4.6.
- DROP VIEW
- 3.4.4.6.1.
- DROP VIEW IF EXISTS
- 3.4.5.
- The GRANT statement
- 3.4.6.
- The REVOKE statement
- 3.4.7.
- The SET statement
- 3.4.7.1.
- SET CATALOG
- 3.4.7.2.
- SET SCHEMA
- 3.4.8.
- The TRUNCATE statement
- 3.4.9.
- Generating DDL from objects
previous : next |
Feedback
Do you have any feedback about this page? We'd love to hear it!