New versions: Dev (3.15) | Latest (3.14) | 3.13 | 3.12 | 3.11 | 3.10 | 3.9 | 3.8 | Old versions: 3.7 | 3.6 | 3.5

CREATE TABLE

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

Arguably the most used DDL statement is the CREATE TABLE statement.

Create a table with columns

There are a few overloads to achieve the same thing with different types of parameters, as always. To keep things simple, only one example is given.

// Create a new table with a column
create.createTable("table")
      .column("column1", INTEGER)
      .execute();

CREATE TABLE AS SELECT

Occasionally, creating a table from a SELECT statement is very useful, copying the source table's data types and data.

// Create a new table from a source SELECT statement
create.createTable("book_archive")
      .as(select(BOOK.ID, BOOK.TITLE).from(BOOK))
      .execute();

Feedback

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

The jOOQ Logo