Which method in jOOQ is used to create a new table in the database?
A) createTable()
B) create()
C) newTable()
D) buildTable()
Answer:
A) createTable()
Explanation:
The createTable()
method in jOOQ is used to create a new table in the database. It allows you to define the table structure, including the columns, data types, and constraints.
For example:
DSLContext create = DSL.using(configuration);
create.createTable("new_table")
.column("id", SQLDataType.INTEGER.identity(true))
.column("name", SQLDataType.VARCHAR(255))
.execute();
In this example, the createTable()
method is used to create a new table named “new_table” with two columns: “id” and “name”.