Home > Software engineering >  JOOQ how to add column with default value into an existing table
JOOQ how to add column with default value into an existing table

Time:06-28

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)))

CodePudding user response:

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

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