Class CreateTable
java.lang.Object
com.northconcepts.datapipeline.jdbc.sql.SqlPart
com.northconcepts.datapipeline.sql.mysql.MySqlPart
com.northconcepts.datapipeline.sql.mysql.CreateTable
Generates a CREATE TABLE statement for MySQL.
Sample Generated SQL:
CREATE TABLE IF NOT EXISTS table_name (
user_id int,
email text,
PRIMARY KEY (user_id)
);
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddColumn(CreateTableColumn column) voidcollectSqlFragment(CodeWriter writer) Writes this part's SQL to the writer; used bySqlPart.getSqlFragment()and by enclosing parts.Returns the columns marked as primary key, in column order; they form the table'sPRIMARY KEYclause.booleanIndicates ifIF NOT EXISTSclause should be included in theCREATE TABLEstatement (default true).setCheckIfNotExists(boolean checkIfNotExists) Indicates ifIF NOT EXISTSclause should be included in theCREATE TABLEstatement (default true).setColumns(List<CreateTableColumn> columns) 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 (
user_id int,
email text
PRIMARY KEY (user_id)
)
Example output (pretty = false):
CREATE TABLE IF NOT EXISTS table_name (user_id int, email text, PRIMARY KEY (user_id))setTableName(String tableName) Methods inherited from class com.northconcepts.datapipeline.sql.mysql.MySqlPart
escapeKeyword, placeBackTicksMethods inherited from class com.northconcepts.datapipeline.jdbc.sql.SqlPart
collectParameterValues, getParameterValues, getSqlFragment, isPretty, printSqlParts, toString
-
Constructor Details
-
CreateTable
public CreateTable() -
CreateTable
-
-
Method Details
-
setPretty
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 (
user_id int,
email text
PRIMARY KEY (user_id)
)
Example output (pretty = false):
CREATE TABLE IF NOT EXISTS table_name (user_id int, email text, PRIMARY KEY (user_id)) -
collectSqlFragment
Description copied from class:SqlPartWrites this part's SQL to the writer; used bySqlPart.getSqlFragment()and by enclosing parts.- Specified by:
collectSqlFragmentin classSqlPart
-
getTableName
-
setTableName
-
isCheckIfNotExists
public boolean isCheckIfNotExists()Indicates ifIF NOT EXISTSclause should be included in theCREATE TABLEstatement (default true). -
setCheckIfNotExists
Indicates ifIF NOT EXISTSclause should be included in theCREATE TABLEstatement (default true). -
getColumns
-
setColumns
-
addColumn
-
getPrimaryKeyColumns
Returns the columns marked as primary key, in column order; they form the table'sPRIMARY KEYclause.
-