JOOQ how to add column with default value into an existing table

Viewed 67

The below DSL can add new column with nullable to existing table, but i don't know how to add a default value in this DSL.

DSL.using(dialect).alterTable(table("tableName"))
                    .add(field(name("newColName"),VARCHAR(32).nullable(false)))
1 Answers

It works the same way as nullable(), directly on the type. Use

VARCHAR(32).nullable(false).default_("abc")
Related