use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class DDLParserTest method testAlterTable_2.
public void testAlterTable_2() throws Exception {
String sql = "ALTER TABLE `test`.`tb1` ADD COLUMN `name` VARCHAR(45) NULL AFTER `fid` ;";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals(//
"ALTER TABLE `test`.`tb1`" + "\n\tADD COLUMN `name` VARCHAR(45) NULL AFTER `fid`", output);
}
use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class DDLParserTest method test_createIndex_0.
public void test_createIndex_0() throws Exception {
String sql = "create index `idx1` ON tb1 (`fname` ASC) ;";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals("CREATE INDEX `idx1` ON tb1 (`fname` ASC)", output);
}
use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class DDLParserTest method testAlterTable_1.
public void testAlterTable_1() throws Exception {
String sql = "alTer table tb_name";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals("ALTER TABLE tb_name", output);
}
use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class DDLParserTest method test_createTable_1.
public void test_createTable_1() throws Exception {
String sql = "crEate tabLe if not exists tb_name (fid int)";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
Assert.assertEquals("CREATE TABLE IF NOT EXISTS tb_name (\n\tfid int\n)", SQLUtils.toMySqlString(stmt));
Assert.assertEquals("create table if not exists tb_name (\n\tfid int\n)", SQLUtils.toMySqlString(stmt, SQLUtils.DEFAULT_LCASE_FORMAT_OPTION));
}
use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class DDLParserTest method testAlterTable_0.
public void testAlterTable_0() throws Exception {
String sql = "alTer ignore table tb_name";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(stmt);
Assert.assertEquals("ALTER IGNORE TABLE tb_name", output);
}
Aggregations