本文整理汇总了Java中com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement类的典型用法代码示例。如果您正苦于以下问题:Java SQLCreateTableStatement类的具体用法?Java SQLCreateTableStatement怎么用?Java SQLCreateTableStatement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SQLCreateTableStatement类属于com.alibaba.druid.sql.ast.statement包,在下文中一共展示了SQLCreateTableStatement类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: hasGlobalColumn
import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement; //导入依赖的package包/类
private static boolean hasGlobalColumn(SQLStatement statement){
for (SQLTableElement tableElement : ((SQLCreateTableStatement)statement).getTableElementList()) {
SQLName sqlName = null;
if (tableElement instanceof SQLColumnDefinition) {
sqlName = ((SQLColumnDefinition)tableElement).getName();
}
if (sqlName != null) {
String simpleName = sqlName.getSimpleName();
simpleName = StringUtil.removeBackquote(simpleName);
if (tableElement instanceof SQLColumnDefinition && GLOBAL_TABLE_MYCAT_COLUMN.equalsIgnoreCase(simpleName)) {
return true;
}
}
}
return false;
}
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:17,代码来源:GlobalTableUtil.java
示例2: statementParse
import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement; //导入依赖的package包/类
@Override
public void statementParse(SchemaConfig schema, RouteResultset rrs, SQLStatement stmt) throws SQLNonTransientException {
MySqlCreateTableStatement createStmt = (MySqlCreateTableStatement)stmt;
if(createStmt.getQuery() != null) {
String msg = "create table from other table not supported :" + stmt;
LOGGER.warn(msg);
throw new SQLNonTransientException(msg);
}
String tableName = StringUtil.removeBackquote(createStmt.getTableSource().toString().toUpperCase());
if(schema.getTables().containsKey(tableName)) {
TableConfig tableConfig = schema.getTables().get(tableName);
AbstractPartitionAlgorithm algorithm = tableConfig.getRule().getRuleAlgorithm();
if(algorithm instanceof SlotFunction){
SQLColumnDefinition column = new SQLColumnDefinition();
column.setDataType(new SQLCharacterDataType("int"));
column.setName(new SQLIdentifierExpr("_slot"));
column.setComment(new SQLCharExpr("自动迁移算法slot,禁止修改"));
((SQLCreateTableStatement)stmt).getTableElementList().add(column);
String sql = createStmt.toString();
rrs.setStatement(sql);
ctx.setSql(sql);
}
}
ctx.addTable(tableName);
}
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:27,代码来源:DruidCreateTableParser.java
示例3: changeCreateTable
import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement; //导入依赖的package包/类
private static String changeCreateTable(SchemaConfig schema,String tableName,String sql) {
if (schema.getTables().containsKey(tableName)) {
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLStatement insertStatement = parser.parseStatement();
if (insertStatement instanceof MySqlCreateTableStatement) {
TableConfig tableConfig = schema.getTables().get(tableName);
AbstractPartitionAlgorithm algorithm = tableConfig.getRule().getRuleAlgorithm();
if (algorithm instanceof SlotFunction) {
SQLColumnDefinition column = new SQLColumnDefinition();
column.setDataType(new SQLCharacterDataType("int"));
column.setName(new SQLIdentifierExpr("_slot"));
column.setComment(new SQLCharExpr("自动迁移算法slot,禁止修改"));
((SQLCreateTableStatement) insertStatement).getTableElementList().add(column);
return insertStatement.toString();
}
}
}
return sql;
}
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:22,代码来源:RouterUtil.java
示例4: hasColumn
import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement; //导入依赖的package包/类
private static boolean hasColumn(SQLStatement statement){
for (SQLTableElement tableElement : ((SQLCreateTableStatement)statement).getTableElementList()) {
SQLName sqlName = null;
if (tableElement instanceof SQLColumnDefinition) {
sqlName = ((SQLColumnDefinition)tableElement).getName();
}
if (sqlName != null) {
String simpleName = sqlName.getSimpleName();
simpleName = StringUtil.removeBackquote(simpleName);
if (tableElement instanceof SQLColumnDefinition && "_slot".equalsIgnoreCase(simpleName)) {
return true;
}
}
}
return false;
}
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:17,代码来源:DruidMysqlCreateTableTest.java
示例5: removeGlobalColumnIfExist
import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement; //导入依赖的package包/类
private static void removeGlobalColumnIfExist(SQLCreateTableStatement statement) {
for (SQLTableElement tableElement : statement.getTableElementList()) {
SQLName sqlName = null;
if (tableElement instanceof SQLColumnDefinition) {
sqlName = ((SQLColumnDefinition) tableElement).getName();
}
if (sqlName != null) {
String simpleName = sqlName.getSimpleName();
simpleName = StringUtil.removeBackQuote(simpleName);
if (GlobalTableUtil.GLOBAL_TABLE_CHECK_COLUMN.equalsIgnoreCase(simpleName)) {
statement.getTableElementList().remove(tableElement);
break;
}
}
}
}
开发者ID:actiontech,项目名称:dble,代码行数:17,代码来源:DruidCreateTableParser.java
示例6: hasColumn
import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement; //导入依赖的package包/类
private static boolean hasColumn(SQLStatement statement) {
for (SQLTableElement tableElement : ((SQLCreateTableStatement) statement).getTableElementList()) {
SQLName sqlName = null;
if (tableElement instanceof SQLColumnDefinition) {
sqlName = ((SQLColumnDefinition) tableElement).getName();
}
if (sqlName != null) {
String simpleName = sqlName.getSimpleName();
simpleName = StringUtil.removeBackQuote(simpleName);
if (tableElement instanceof SQLColumnDefinition && "_slot".equalsIgnoreCase(simpleName)) {
return true;
}
}
}
return false;
}
开发者ID:actiontech,项目名称:dble,代码行数:18,代码来源:DruidMysqlCreateTableTest.java
示例7: addColumnIfCreate
import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement; //导入依赖的package包/类
static String addColumnIfCreate(String sql, SQLStatement statement) {
if (isCreate(statement) && sql.trim().toUpperCase().startsWith("CREATE TABLE ") && !hasGlobalColumn(statement)) {
SQLColumnDefinition column = new SQLColumnDefinition();
column.setDataType(new SQLCharacterDataType("bigint"));
column.setName(new SQLIdentifierExpr(GLOBAL_TABLE_MYCAT_COLUMN));
column.setComment(new SQLCharExpr("全局表保存修改时间戳的字段名"));
((SQLCreateTableStatement)statement).getTableElementList().add(column);
}
return statement.toString();
}
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:11,代码来源:GlobalTableUtil.java
示例8: getDDLTableSource
import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement; //导入依赖的package包/类
private static SQLExprTableSource getDDLTableSource(SQLStatement statement) {
SQLExprTableSource source = null;
if (statement instanceof SQLAlterTableStatement) {
source = ((SQLAlterTableStatement)statement).getTableSource();
} else if (isCreate(statement)) {
source = ((SQLCreateTableStatement)statement).getTableSource();
}
return source;
}
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:11,代码来源:GlobalTableUtil.java
示例9: find
import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement; //导入依赖的package包/类
@Override
public TableMeta find(String schema, String table) {
List<String> keys = Arrays.asList(schema, table);
TableMeta tableMeta = tableMetas.get(keys);
if (tableMeta == null) {
synchronized (this) {
tableMeta = tableMetas.get(keys);
if (tableMeta == null) {
Schema schemaRep = repository.findSchema(schema);
if (schema == null) {
return null;
}
SchemaObject data = schemaRep.findTable(table);
if (data == null) {
return null;
}
SQLStatement statement = data.getStatement();
if (statement == null) {
return null;
}
if (statement instanceof SQLCreateTableStatement) {
tableMeta = parse((SQLCreateTableStatement) statement);
}
if (tableMeta != null) {
if (table != null) {
tableMeta.setTable(table);
}
if (schema != null) {
tableMeta.setSchema(schema);
}
tableMetas.put(keys, tableMeta);
}
}
}
}
return tableMeta;
}
开发者ID:alibaba,项目名称:canal,代码行数:40,代码来源:MemoryTableMeta.java
示例10: parse
import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement; //导入依赖的package包/类
private TableMeta parse(SQLCreateTableStatement statement) {
int size = statement.getTableElementList().size();
if (size > 0) {
TableMeta tableMeta = new TableMeta();
for (int i = 0; i < size; ++i) {
SQLTableElement element = statement.getTableElementList().get(i);
processTableElement(element, tableMeta);
}
return tableMeta;
}
return null;
}
开发者ID:alibaba,项目名称:canal,代码行数:14,代码来源:MemoryTableMeta.java
示例11: isCreate
import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement; //导入依赖的package包/类
private static boolean isCreate(SQLStatement statement) {
return statement instanceof SQLCreateTableStatement;
}
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:4,代码来源:GlobalTableUtil.java
示例12: initTableMeta
import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement; //导入依赖的package包/类
private StructureMeta.TableMeta initTableMeta(String table, String sql, long timeStamp) {
SQLStatementParser parser = new MySqlStatementParser(sql);
SQLCreateTableStatement createStatement = parser.parseCreateTable();
return MetaHelper.initTableMeta(table, createStatement, timeStamp);
}
开发者ID:actiontech,项目名称:dble,代码行数:6,代码来源:AbstractTableMetaHandler.java
注:本文中的com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论