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

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.

ALTER TABLE .. ADD COLUMNS

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

If multiple columns should be added atomically, and to save server round trips, some RDBMS support adding multiple columns to a table using a single ALTER TABLE statement.

// Adding several columns to a table in one go
create.alterTable("table").add(field(name("column1"), INTEGER), field(name("column2"), INTEGER)).execute();

Dialect support

This example using jOOQ:

alterTable("t").add(field("c1", INTEGER), field("c2", INTEGER))

Translates to the following dialect specific expressions:

ASE

ALTER TABLE t ADD 
  c1 int NULL,
  c2 int NULL

Aurora MySQL, Aurora Postgres, MariaDB, MemSQL, MySQL, Postgres, YugabyteDB

ALTER TABLE t ADD c1 int,
ADD c2 int

BigQuery

ALTER TABLE t ADD COLUMN c1 int64,
ADD COLUMN c2 int64

ClickHouse

ALTER TABLE t ADD COLUMN c1 Nullable(integer),
ADD COLUMN c2 Nullable(integer)

CockroachDB

ALTER TABLE t ADD c1 int4,
ADD c2 int4

DB2

ALTER TABLE t ADD c1 integer
ADD c2 integer

Firebird, Teradata

ALTER TABLE t ADD c1 integer,
ADD c2 integer

H2

ALTER TABLE t ADD (
  c1 int,
  c2 int
)

Hana, Informix

ALTER TABLE t ADD (
  c1 integer,
  c2 integer
)

Oracle, Snowflake

ALTER TABLE t ADD (
  c1 number(10),
  c2 number(10)
)

SQLDataWarehouse, SQLServer

ALTER TABLE t ADD 
  c1 int,
  c2 int

Access, Derby, DuckDB, Exasol, HSQLDB, Redshift, SQLite, Sybase, Trino, Vertica

/* 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