public class CreateTable extends H2SqlPart
Generates a CREATE TABLE statement for H2.
CREATE TABLE IF NOT EXISTS table_name (
user_id int,
email text,
PRIMARY KEY (user_id)
);
| Constructor and Description |
|---|
CreateTable() |
CreateTable(String tableName)
Constructs a CreateTable with the specified table name.
|
| Modifier and Type | Method and Description |
|---|---|
CreateTable |
addColumn(CreateTableColumn column)
Adds a column to this table.
|
void |
collectSqlFragment(CodeWriter writer) |
List<CreateTableColumn> |
getColumns()
Returns the list of columns.
|
List<CreateTableColumn> |
getPrimaryKeyColumns()
Returns the list of primary key columns.
|
String |
getTableName()
Returns the table name.
|
boolean |
isCheckIfNotExists()
Indicates if
IF NOT EXISTS clause should be included in the CREATE TABLE statement (default true). |
CreateTable |
setCheckIfNotExists(boolean checkIfNotExists)
Indicates if
IF NOT EXISTS clause should be included in the CREATE TABLE statement (default true). |
CreateTable |
setColumns(List<CreateTableColumn> columns)
Sets the columns.
|
CreateTable |
setPretty(boolean pretty)
Indicates if line breaks and indentations should be added to output DDL (default false).
Example output (pretty = true):
CREATE TABLE IF NOT EXISTS table_name (
Example output (pretty = false): CREATE TABLE IF NOT EXISTS table_name (user_id int, email text, PRIMARY KEY (user_id)) |
CreateTable |
setTableName(String tableName)
Sets the table name.
|
escapeKeyword, placeBackTickscollectParameterValues, getParameterValues, getSqlFragment, isPretty, printSqlParts, toStringpublic CreateTable()
public CreateTable(String tableName)
tableName - the table namepublic CreateTable setPretty(boolean pretty)
CREATE TABLE IF NOT EXISTS table_name (
user_id int,
email text
PRIMARY KEY (user_id)
)
CREATE TABLE IF NOT EXISTS table_name (user_id int, email text, PRIMARY KEY (user_id))public void collectSqlFragment(CodeWriter writer)
collectSqlFragment in class SqlPartpublic String getTableName()
public CreateTable setTableName(String tableName)
tableName - the table namepublic boolean isCheckIfNotExists()
IF NOT EXISTS clause should be included in the CREATE TABLE statement (default true).public CreateTable setCheckIfNotExists(boolean checkIfNotExists)
IF NOT EXISTS clause should be included in the CREATE TABLE statement (default true).public List<CreateTableColumn> getColumns()
public CreateTable setColumns(List<CreateTableColumn> columns)
columns - the list of columnspublic CreateTable addColumn(CreateTableColumn column)
column - the column to addpublic List<CreateTableColumn> getPrimaryKeyColumns()
Copyright (c) 2006-2026 North Concepts Inc. All Rights Reserved.