use of com.alibaba.druid.sql.ast.statement.SQLAlterTableStatement in project druid by alibaba.
the class CreateCompareTest_cycle method test_0.
public void test_0() throws Exception {
String sql = "CREATE TABLE t0 (\n" + "\tint bigint\n" + ");\n" + "\n" + "CREATE TABLE t1 (\n" + "\tint bigint\n" + ");\n" + "CREATE TABLE t2 (\n" + "\tint bigint,\n" + "\tFOREIGN KEY (id)\n" + "\t\tREFERENCES t1 (id)\n" + ");\n" + "\n" + "CREATE TABLE t3 (\n" + "\tint bigint,\n" + "\tFOREIGN KEY (id)\n" + "\t\tREFERENCES t2 (id)\n" + ");\n" + "\n" + "CREATE TABLE t4 (\n" + "\tint bigint,\n" + "\tFOREIGN KEY (id)\n" + "\t\tREFERENCES t3 (id),\n" + "\tFOREIGN KEY (id)\n" + "\t\tREFERENCES t4 (id)\n" + ");\n" + "\n" + "CREATE TABLE t5 (\n" + "\tint bigint,\n" + "\tFOREIGN KEY (id)\n" + "\t\tREFERENCES t4 (id)\n" + ");\n" + "\n" + "CREATE TABLE t6 (\n" + "\tint bigint,\n" + "\tFOREIGN KEY (id)\n" + "\t\tREFERENCES t5 (id)\n" + ");\n" + "\n" + "CREATE TABLE t7 (\n" + "\tint bigint,\n" + "\tFOREIGN KEY (id)\n" + "\t\tREFERENCES t6 (id)\n" + ");\n" + "\n" + "\n" + "CREATE TABLE t8 (\n" + "\tint bigint,\n" + "\tFOREIGN KEY (id)\n" + "\t\tREFERENCES t7 (id)\n" + ");\n" + "\n" + "CREATE TABLE t9 (\n" + "\tint bigint,\n" + "\tFOREIGN KEY (id)\n" + "\t\tREFERENCES t8 (id)\n" + ");";
List stmtList = SQLUtils.parseStatements(sql, JdbcConstants.ORACLE);
SQLCreateTableStatement.sort(stmtList);
String sortedSql = SQLUtils.toSQLString(stmtList, JdbcConstants.ORACLE);
System.out.println(sortedSql);
assertEquals("t0", ((SQLCreateTableStatement) stmtList.get(9)).getName().getSimpleName());
assertEquals("t9", ((SQLCreateTableStatement) stmtList.get(8)).getName().getSimpleName());
assertEquals("t8", ((SQLCreateTableStatement) stmtList.get(7)).getName().getSimpleName());
assertEquals("t7", ((SQLCreateTableStatement) stmtList.get(6)).getName().getSimpleName());
assertEquals("t6", ((SQLCreateTableStatement) stmtList.get(5)).getName().getSimpleName());
assertEquals("t5", ((SQLCreateTableStatement) stmtList.get(4)).getName().getSimpleName());
assertEquals("t4", ((SQLCreateTableStatement) stmtList.get(3)).getName().getSimpleName());
assertEquals("t3", ((SQLCreateTableStatement) stmtList.get(2)).getName().getSimpleName());
assertEquals("t2", ((SQLCreateTableStatement) stmtList.get(1)).getName().getSimpleName());
assertEquals("t1", ((SQLCreateTableStatement) stmtList.get(0)).getName().getSimpleName());
assertEquals("t4", ((SQLAlterTableStatement) stmtList.get(10)).getName().getSimpleName());
assertEquals(11, stmtList.size());
}
use of com.alibaba.druid.sql.ast.statement.SQLAlterTableStatement in project druid by alibaba.
the class MySqlAlterTableTest54 method test_2.
public void test_2() throws Exception {
String sql = "alter table event_log storage_policy = 'MIXED' hot_partition_count = 10;";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLAlterTableStatement stmt = (SQLAlterTableStatement) parser.parseStatementList().get(0);
assertEquals(2, stmt.getTableOptions().size());
String formatSql = SQLUtils.toSQLString(stmt);
assertEquals("ALTER TABLE event_log\n" + "\tSTORAGE_POLICY = 'MIXED' HOT_PARTITION_COUNT = 10;", formatSql);
}
use of com.alibaba.druid.sql.ast.statement.SQLAlterTableStatement in project druid by alibaba.
the class MySqlAlterTableTest54 method test_3.
public void test_3() throws Exception {
String sql = "alter table event_log hot_partition_count = 10;";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLAlterTableStatement stmt = (SQLAlterTableStatement) parser.parseStatementList().get(0);
assertEquals(1, stmt.getTableOptions().size());
String formatSql = SQLUtils.toSQLString(stmt);
assertEquals("ALTER TABLE event_log\n" + "\tHOT_PARTITION_COUNT = 10;", formatSql);
}
use of com.alibaba.druid.sql.ast.statement.SQLAlterTableStatement in project druid by alibaba.
the class MySqlAlterTableTest54 method test_7.
public void test_7() throws Exception {
String sql = "alter table event_log storage_policy = COLD";
MySqlStatementParser parser = new MySqlStatementParser(sql);
try {
SQLAlterTableStatement stmt = (SQLAlterTableStatement) parser.parseStatementList().get(0);
fail();
} catch (Exception e) {
}
}
use of com.alibaba.druid.sql.ast.statement.SQLAlterTableStatement in project druid by alibaba.
the class MySqlAlterTableTest54 method test_0.
public void test_0() throws Exception {
String sql = "alter table event_log storage_policy = 'HOT'";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLAlterTableStatement stmt = (SQLAlterTableStatement) parser.parseStatementList().get(0);
assertEquals(1, stmt.getTableOptions().size());
String formatSql = SQLUtils.toSQLString(stmt);
assertEquals("ALTER TABLE event_log\n" + "\tSTORAGE_POLICY = 'HOT'", formatSql);
}
Aggregations