public abstract class DBDDLGenerator<T extends DBMSHandler> extends Object
Modifier and Type | Class and Description |
---|---|
static class |
DBDDLGenerator.DDLActionType
DDLActionType for DDLScript generation
|
Modifier and Type | Field and Description |
---|---|
protected String |
alterColumnPhrase |
protected String |
databaseObjectName |
protected String |
DATATYPE_BLOB |
protected String |
DATATYPE_BOOLEAN |
protected String |
DATATYPE_CHAR |
protected String |
DATATYPE_CLOB |
protected String |
DATATYPE_DATE |
protected String |
DATATYPE_DECIMAL |
protected String |
DATATYPE_FLOAT |
protected String |
DATATYPE_INT_BIG |
protected String |
DATATYPE_INT_SMALL |
protected String |
DATATYPE_INTEGER |
protected String |
DATATYPE_TIME |
protected String |
DATATYPE_TIMESTAMP |
protected String |
DATATYPE_UNIQUEID |
protected String |
DATATYPE_VARCHAR |
protected T |
dbms |
protected boolean |
ddlColumnDefaults |
protected boolean |
namePrimaryKeyConstraint |
Modifier | Constructor and Description |
---|---|
protected |
DBDDLGenerator(T dbmsHandler) |
Modifier and Type | Method and Description |
---|---|
protected void |
addAlterTableStmt(DBColumn col,
DBSQLBuilder sql,
DBSQLScript script) |
protected void |
addCreateIndexStmt(DBIndex index,
DBSQLBuilder sql,
DBSQLScript script) |
protected void |
addCreateRelationStmt(DBRelation rel,
DBSQLBuilder sql,
DBSQLScript script) |
protected void |
addCreateTableStmt(DBTable table,
DBSQLBuilder sql,
DBSQLScript script) |
protected void |
addCreateViewStmt(DBView v,
DBSQLBuilder sql,
DBSQLScript script) |
protected void |
alterTable(DBTableColumn col,
DBDDLGenerator.DDLActionType type,
DBSQLScript script)
Appends the DDL-Script for altering a table to an SQL-Script
|
protected boolean |
appendColumnDataType(DataType type,
double size,
DBTableColumn c,
DBSQLBuilder sql)
appends the data type of a column
|
protected void |
appendColumnDesc(DBTableColumn c,
boolean alter,
DBSQLBuilder sql)
Appends a table column definition to a ddl statement
|
protected void |
appendElementName(DBSQLBuilder sql,
String name) |
protected void |
createDatabase(DBDatabase db,
DBSQLScript script)
Appends the DDL-Script for creating the given database to an SQL-Script
This includes the generation of all tables, views and relations. |
protected void |
createIndex(DBTable t,
DBIndex idx,
DBSQLScript script)
Appends the DDL-Script for creating a single index to an SQL-Script
|
protected void |
createRelation(DBRelation r,
DBSQLScript script)
Appends the DDL-Script for creating the given foreign-key relation to an SQL-Script
|
protected void |
createTable(DBTable t,
DBSQLScript script)
Appends the DDL-Script for creating the given table to an SQL-Script
|
protected void |
createTableIndexes(DBTable t,
DBIndex pk,
DBSQLScript script)
Appends the DDL-Script for creating all indexes of table (except the primary key) to an SQL-Script
|
protected void |
createView(DBView v,
DBSQLScript script)
Appends the DDL-Script for creating the given view to an SQL-Script
|
protected void |
dropDatabase(DBDatabase db,
DBSQLScript script)
Appends the DDL-Script for dropping a database to the given script object
|
protected void |
dropObject(String schema,
String name,
String objType,
DBSQLScript script)
Appends the DDL-Script for dropping a database object to an SQL-Script
|
void |
getDDLScript(DBDDLGenerator.DDLActionType type,
DBObject dbo,
DBSQLScript script)
Appends the required DLL commands to create, drop or alter an object to the supplied DBDQLScript.
|
boolean |
isDDLColumnDefaults() |
void |
setDDLColumnDefaults(boolean ddlColumnDefaults)
Set true if column default values should be included in DDL Statements
|
protected final T extends DBMSHandler dbms
protected String DATATYPE_INT_SMALL
protected String DATATYPE_INTEGER
protected String DATATYPE_INT_BIG
protected String DATATYPE_CHAR
protected String DATATYPE_VARCHAR
protected String DATATYPE_DATE
protected String DATATYPE_TIME
protected String DATATYPE_TIMESTAMP
protected String DATATYPE_BOOLEAN
protected String DATATYPE_DECIMAL
protected String DATATYPE_FLOAT
protected String DATATYPE_CLOB
protected String DATATYPE_BLOB
protected String DATATYPE_UNIQUEID
protected boolean namePrimaryKeyConstraint
protected String alterColumnPhrase
protected String databaseObjectName
protected boolean ddlColumnDefaults
protected DBDDLGenerator(T dbmsHandler)
public boolean isDDLColumnDefaults()
true
if column default values are created with dll statements or false
if notpublic void setDDLColumnDefaults(boolean ddlColumnDefaults)
ddlColumnDefaults
- true
if dll statements should include
column default values or false
if notprotected void addCreateTableStmt(DBTable table, DBSQLBuilder sql, DBSQLScript script)
protected void addCreateIndexStmt(DBIndex index, DBSQLBuilder sql, DBSQLScript script)
protected void addCreateRelationStmt(DBRelation rel, DBSQLBuilder sql, DBSQLScript script)
protected void addCreateViewStmt(DBView v, DBSQLBuilder sql, DBSQLScript script)
protected void addAlterTableStmt(DBColumn col, DBSQLBuilder sql, DBSQLScript script)
protected boolean appendColumnDataType(DataType type, double size, DBTableColumn c, DBSQLBuilder sql)
type
- the typesize
- the sizesql
- the builder that we will append toprotected void appendColumnDesc(DBTableColumn c, boolean alter, DBSQLBuilder sql)
c
- the column which description to appendalter
- true if altering an existing column or false otherwisesql
- the sql builder objectpublic void getDDLScript(DBDDLGenerator.DDLActionType type, DBObject dbo, DBSQLScript script)
type
- operation to perform (CREATE, DROP, ALTER)dbo
- the object for which to perform the operation (DBDatabase, DBTable, DBView, DBColumn, DBRelation)script
- the script to which to add the DDL command(s)protected void createDatabase(DBDatabase db, DBSQLScript script)
db
- the database to createscript
- the sql script to which to append the dll command(s)protected void dropDatabase(DBDatabase db, DBSQLScript script)
db
- the database to dropscript
- the sql script to which to append the dll command(s)protected void createTable(DBTable t, DBSQLScript script)
t
- the table to createscript
- the sql script to which to append the dll command(s)protected void createTableIndexes(DBTable t, DBIndex pk, DBSQLScript script)
t
- the table to createpk
- the primary key index to ignorescript
- the sql script to which to append the dll command(s)protected void createIndex(DBTable t, DBIndex idx, DBSQLScript script)
t
- the tableidx
- the index to createscript
- the sql script to which to append the dll command(s)protected void createRelation(DBRelation r, DBSQLScript script)
r
- the relation to createscript
- the sql script to which to append the dll command(s)protected void alterTable(DBTableColumn col, DBDDLGenerator.DDLActionType type, DBSQLScript script)
col
- the column which to add, modify or droptype
- the type of operation to perform (CREATE | MODIFY | DROP)script
- the sql script to which to append the dll command(s)protected void createView(DBView v, DBSQLScript script)
v
- the view to createscript
- the sql script to which to append the dll command(s)protected void dropObject(String schema, String name, String objType, DBSQLScript script)
name
- the name of the object to deleteobjType
- the type of object to delete (TABLE, COLUMN, VIEW, RELATION, etc)script
- the sql script to which to append the dll command(s)protected void appendElementName(DBSQLBuilder sql, String name)
Copyright © 2008–2023 Apache Software Foundation. All rights reserved.