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

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.

Table of contents

4.4.1.
The ALTER statement
4.4.1.1.
ALTER INDEX
4.4.1.2.
ALTER SCHEMA
4.4.1.3.
ALTER SEQUENCE
4.4.1.4.
ALTER TABLE
4.4.1.5.
ALTER VIEW
4.4.1.5.1.
ALTER VIEW .. RENAME
4.4.1.5.2.
ALTER VIEW IF EXISTS
4.4.2.
The CREATE statement
4.4.2.1.
CREATE INDEX
4.4.2.2.
CREATE SCHEMA
4.4.2.3.
CREATE SEQUENCE
4.4.2.4.
CREATE TABLE
4.4.2.4.1.
Columns
4.4.2.4.2.
Nullability
4.4.2.4.3.
Defaults
4.4.2.4.4.
Identities
4.4.2.4.5.
Primary key
4.4.2.4.6.
Unique constraints
4.4.2.4.7.
Foreign keys
4.4.2.4.8.
Check constraints
4.4.2.4.9.
From a SELECT
4.4.2.4.10.
Temporary tables
4.4.2.5.
CREATE VIEW
4.4.2.5.1.
WITH CHECK OPTION
4.4.2.5.2.
WITH READ ONLY
4.4.3.
The DROP statement
4.4.3.1.
DROP INDEX
4.4.3.1.1.
IF EXISTS
4.4.3.2.
DROP SCHEMA
4.4.3.2.1.
IF EXISTS
4.4.3.3.
DROP SEQUENCE
4.4.3.3.1.
IF EXISTS
4.4.3.4.
DROP TABLE
4.4.3.4.1.
IF EXISTS
4.4.3.5.
DROP VIEW
4.4.3.5.1.
IF EXISTS
4.4.4.
The TRUNCATE statement
4.4.5.
Generating DDL from objects

previous : next

References to this page

Feedback

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

The jOOQ Logo