public abstract class GeneralDDLOperations extends Object implements DDLOperations
| Modifier and Type | Field and Description |
|---|---|
protected Connection |
conn |
| Constructor and Description |
|---|
GeneralDDLOperations() |
GeneralDDLOperations(Connection conn) |
| Modifier and Type | Method and Description |
|---|---|
void |
addColumn(String tableCode,
TableField column)
添加列
|
protected void |
appendColumnSQL(TableField field,
StringBuilder sbCreate) |
protected void |
appendColumnsSQL(TableInfo tableInfo,
StringBuilder sbCreate,
boolean fieldStartNewLine) |
protected void |
appendColumnTypeSQL(TableField field,
StringBuilder sbCreate) |
protected void |
appendPkColumnSql(TableInfo tableInfo,
StringBuilder sbCreate) |
protected void |
appendPkSql(TableInfo tableInfo,
StringBuilder sbCreate) |
static org.apache.commons.lang3.tuple.Pair<Integer,String> |
checkTableWellDefined(TableInfo tableInfo)
返回格式检查结果
|
static org.apache.commons.lang3.tuple.Pair<Integer,String> |
checkViewWellDefined(TableInfo tableInfo) |
static GeneralDDLOperations |
createDDLOperations(Connection conn) |
static GeneralDDLOperations |
createDDLOperations(DBType dbtype) |
void |
createSequence(String sequenceName)
创建sequence
|
void |
createTable(TableInfo tableInfo)
创建表
|
void |
dropColumn(String tableCode,
String columnCode)
删除列
|
void |
dropTable(String tableCode)
删除表
|
String |
makeAddColumnSql(String tableCode,
TableField column)
添加列
|
String |
makeCreateSequenceSql(String sequenceName)
创建序列
用表来模拟sequence
create table simulate_sequence (seqname varchar(100) not null primary key,
currvalue integer, increment integer);
|
String |
makeCreateTableSql(TableInfo tableInfo,
boolean fieldStartNewLine)
创建表
|
String |
makeCreateViewSql(String selectSql,
String viewName)
创建视图
|
String |
makeDropColumnSql(String tableCode,
String columnCode)
删除列
|
String |
makeDropTableSql(String tableCode)
删除表
|
List<String> |
makeReconfigurationColumnSqls(String tableCode,
String columnCode,
TableField column)
重构列,涉及到内容格式的转换,需要新建一个列,将旧列中的数据转换到新列中,然后在删除旧列
|
String |
makeRenameColumnSql(String tableCode,
String columnCode,
TableField column)
重命名列
|
void |
modifyColumn(String tableCode,
TableField oldColumn,
TableField column)
修改列定义 ,比如 修改 varchar 的长度
|
static SimpleTableInfo |
parseDDL(String createSql) |
void |
reconfigurationColumn(String tableCode,
String columnCode,
TableField column)
重构列,涉及到内容格式的转换,需要新建一个列,将旧列中的数据转换到新列中,然后在删除旧列
|
void |
renameColumn(String tableCode,
String columnCode,
TableField column)
重命名列
|
void |
setConnect(Connection conn) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitmakeCreateTableSql, makeModifyColumnSqlprotected Connection conn
public GeneralDDLOperations()
public GeneralDDLOperations(Connection conn)
public static GeneralDDLOperations createDDLOperations(DBType dbtype)
public static GeneralDDLOperations createDDLOperations(Connection conn) throws SQLException
SQLExceptionpublic static final org.apache.commons.lang3.tuple.Pair<Integer,String> checkTableWellDefined(TableInfo tableInfo)
tableInfo - 表public static final org.apache.commons.lang3.tuple.Pair<Integer,String> checkViewWellDefined(TableInfo tableInfo)
public static final SimpleTableInfo parseDDL(String createSql)
public void setConnect(Connection conn)
public String makeCreateSequenceSql(String sequenceName)
makeCreateSequenceSql in interface DDLOperationssequenceName - 序列public String makeCreateTableSql(TableInfo tableInfo, boolean fieldStartNewLine)
DDLOperationsmakeCreateTableSql in interface DDLOperationstableInfo - 表fieldStartNewLine - 是否每个字段单独一行protected void appendPkSql(TableInfo tableInfo, StringBuilder sbCreate)
protected void appendPkColumnSql(TableInfo tableInfo, StringBuilder sbCreate)
protected void appendColumnsSQL(TableInfo tableInfo, StringBuilder sbCreate, boolean fieldStartNewLine)
protected void appendColumnTypeSQL(TableField field, StringBuilder sbCreate)
protected void appendColumnSQL(TableField field, StringBuilder sbCreate)
public String makeDropTableSql(String tableCode)
DDLOperationsmakeDropTableSql in interface DDLOperationstableCode - 表public String makeAddColumnSql(String tableCode, TableField column)
DDLOperationsmakeAddColumnSql in interface DDLOperationstableCode - 表column - 字段public String makeDropColumnSql(String tableCode, String columnCode)
DDLOperationsmakeDropColumnSql in interface DDLOperationstableCode - 表代码columnCode - 字段代码public String makeRenameColumnSql(String tableCode, String columnCode, TableField column)
DDLOperationsmakeRenameColumnSql in interface DDLOperationstableCode - 表代码columnCode - 字段代码column - 字段public List<String> makeReconfigurationColumnSqls(String tableCode, String columnCode, TableField column)
DDLOperationsmakeReconfigurationColumnSqls in interface DDLOperationstableCode - 表代码columnCode - 字段代码column - 字段public void createSequence(String sequenceName) throws SQLException
DDLOperationscreateSequence in interface DDLOperationssequenceName - sequenceNameSQLException - SQLExceptionpublic void createTable(TableInfo tableInfo) throws SQLException
DDLOperationscreateTable in interface DDLOperationstableInfo - 表SQLException - SQLExceptionpublic void dropTable(String tableCode) throws SQLException
DDLOperationsdropTable in interface DDLOperationstableCode - 表代码SQLException - SQLExceptionpublic void addColumn(String tableCode, TableField column) throws SQLException
DDLOperationsaddColumn in interface DDLOperationstableCode - 表代码column - 字段SQLException - SQLExceptionpublic void modifyColumn(String tableCode, TableField oldColumn, TableField column) throws SQLException
DDLOperationsmodifyColumn in interface DDLOperationstableCode - 表代码oldColumn - 老的字段column - 字段SQLException - SQLExceptionpublic void dropColumn(String tableCode, String columnCode) throws SQLException
DDLOperationsdropColumn in interface DDLOperationstableCode - 表代码columnCode - 字段代码SQLException - SQLExceptionpublic void renameColumn(String tableCode, String columnCode, TableField column) throws SQLException
DDLOperationsrenameColumn in interface DDLOperationstableCode - 表代码columnCode - 字段代码column - 字段SQLException - SQLExceptionpublic void reconfigurationColumn(String tableCode, String columnCode, TableField column) throws SQLException
DDLOperationsreconfigurationColumn in interface DDLOperationstableCode - 表代码columnCode - 字段代码column - 字段SQLException - SQLExceptionpublic String makeCreateViewSql(String selectSql, String viewName)
DDLOperationsmakeCreateViewSql in interface DDLOperationsselectSql - select语句viewName - 视图名称Copyright © 2024 江苏南大先腾信息产业股份有限公司. All rights reserved.