public class CreateTable extends PostgresSqlPart
Generates a CREATE TABLE
statement for PostgreSQL.
CREATE TABLE IF NOT EXISTS "table_name" (
"user_id" serial,
"email" text,
PRIMARY KEY ("user_id")
);
Constructor and Description |
---|
CreateTable() |
CreateTable(String tableName) |
Modifier and Type | Method and Description |
---|---|
CreateTable |
addColumn(CreateTableColumn column) |
void |
collectSqlFragment(CodeWriter writer) |
List<CreateTableColumn> |
getColumns() |
List<CreateTableColumn> |
getPrimaryKeyColumns() |
String |
getTableName() |
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) |
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" serial, "email" text, PRIMARY KEY ("user_id")) |
CreateTable |
setTableName(String tableName) |
escapeKeyword
collectParameterValues, getParameterValues, getSqlFragment, isPretty, printSqlParts, toString
public CreateTable()
public CreateTable(String tableName)
public CreateTable setPretty(boolean pretty)
CREATE TABLE IF NOT EXISTS "table_name" (
"user_id" serial,
"email" text
PRIMARY KEY ("user_id")
)
CREATE TABLE IF NOT EXISTS "table_name" ("user_id" serial, "email" text, PRIMARY KEY ("user_id"))
public void collectSqlFragment(CodeWriter writer)
collectSqlFragment
in class SqlPart
public String getTableName()
public CreateTable setTableName(String tableName)
public 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)
public CreateTable addColumn(CreateTableColumn column)
public List<CreateTableColumn> getPrimaryKeyColumns()
Copyright (c) 2006-2023 North Concepts Inc. All Rights Reserved.