use of com.alibaba.druid.sql.dialect.oracle.visitor.OracleSchemaStatVisitor in project druid by alibaba.
the class OracleCreateTableTest28 method test_types.
public void test_types() throws Exception {
//
String sql = //
"CREATE TABLE divisions " + //
" (div_no NUMBER CONSTRAINT check_divno" + //
" CHECK (div_no BETWEEN 10 AND 99) " + //
" DISABLE, " + //
" div_name VARCHAR2(9) CONSTRAINT check_divname" + //
" CHECK (div_name = UPPER(div_name)) " + //
" DISABLE, " + //
" office VARCHAR2(10) CONSTRAINT check_office" + //
" CHECK (office IN ('DALLAS','BOSTON'," + //
" 'PARIS','TOKYO')) " + " DISABLE); ";
OracleStatementParser parser = new OracleStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement stmt = statementList.get(0);
print(statementList);
Assert.assertEquals(1, statementList.size());
Assert.assertEquals(//
"CREATE TABLE divisions (" + //
"\n\tdiv_no NUMBER" + //
"\n\t\tCONSTRAINT check_divno CHECK (div_no BETWEEN 10 AND 99) DISABLE," + //
"\n\tdiv_name VARCHAR2(9)" + //
"\n\t\tCONSTRAINT check_divname CHECK (div_name = UPPER(div_name)) DISABLE," + //
"\n\toffice VARCHAR2(10)" + //
"\n\t\tCONSTRAINT check_office CHECK (office IN ('DALLAS', 'BOSTON', 'PARIS', 'TOKYO')) DISABLE" + //
"\n)", SQLUtils.toSQLString(stmt, JdbcConstants.ORACLE));
OracleSchemaStatVisitor visitor = new OracleSchemaStatVisitor();
stmt.accept(visitor);
System.out.println("Tables : " + visitor.getTables());
System.out.println("fields : " + visitor.getColumns());
System.out.println("coditions : " + visitor.getConditions());
System.out.println("relationships : " + visitor.getRelationships());
System.out.println("orderBy : " + visitor.getOrderByColumns());
Assert.assertEquals(1, visitor.getTables().size());
Assert.assertEquals(3, visitor.getColumns().size());
Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("divisions", "div_no")));
}
use of com.alibaba.druid.sql.dialect.oracle.visitor.OracleSchemaStatVisitor in project druid by alibaba.
the class OracleCreateTableTest16 method test_types.
public void test_types() throws Exception {
//
String sql = //
"create table T (" + //
"F1 INTERVAL YEAR TO MONTH," + //
"F2 INTERVAL YEAR (3) TO MONTH," + //
"F3 INTERVAL DAY TO SECOND," + //
"F4 INTERVAL DAY (3) TO SECOND," + //
"F5 INTERVAL DAY TO SECOND (9)," + //
"F6 INTERVAL DAY (3) TO SECOND (9)" + ") ";
OracleStatementParser parser = new OracleStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement statement = statementList.get(0);
print(statementList);
Assert.assertEquals(1, statementList.size());
Assert.assertEquals(//
"CREATE TABLE T (" + //
"\n\tF1 INTERVAL YEAR TO MONTH," + //
"\n\tF2 INTERVAL YEAR(3) TO MONTH," + //
"\n\tF3 INTERVAL DAY TO SECOND," + //
"\n\tF4 INTERVAL DAY(3) TO SECOND," + //
"\n\tF5 INTERVAL DAY TO SECOND(9)," + //
"\n\tF6 INTERVAL DAY(3) TO SECOND(9)" + "\n)", SQLUtils.toSQLString(statement, JdbcConstants.ORACLE));
OracleSchemaStatVisitor visitor = new OracleSchemaStatVisitor();
statement.accept(visitor);
System.out.println("Tables : " + visitor.getTables());
System.out.println("fields : " + visitor.getColumns());
System.out.println("coditions : " + visitor.getConditions());
System.out.println("relationships : " + visitor.getRelationships());
System.out.println("orderBy : " + visitor.getOrderByColumns());
Assert.assertEquals(1, visitor.getTables().size());
Assert.assertEquals(6, visitor.getColumns().size());
Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("T", "F1")));
Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("T", "F2")));
Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("T", "F3")));
Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("T", "F4")));
Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("T", "F5")));
Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("T", "F6")));
}
use of com.alibaba.druid.sql.dialect.oracle.visitor.OracleSchemaStatVisitor in project druid by alibaba.
the class OracleCreateTableTest17 method test_types.
public void test_types() throws Exception {
//
String sql = //
"create table ACT_HI_PROCINST ( " + //
"ID_ NVARCHAR2(64) not null, " + //
"PROC_INST_ID_ NVARCHAR2(64) not null, " + //
"BUSINESS_KEY_ NVARCHAR2(255), " + //
"PROC_DEF_ID_ NVARCHAR2(64) not null, " + //
"START_TIME_ TIMESTAMP(6) not null, " + //
"END_TIME_ TIMESTAMP(6), " + //
"DURATION_ NUMBER(19,0), " + //
"START_USER_ID_ NVARCHAR2(255), " + //
"START_ACT_ID_ NVARCHAR2(255), " + //
"END_ACT_ID_ NVARCHAR2(255), " + //
"SUPER_PROCESS_INSTANCE_ID_ NVARCHAR2(64), " + //
"DELETE_REASON_ NVARCHAR2(2000), " + //
"primary key (ID_), " + //
"unique (PROC_INST_ID_) " + ")";
OracleStatementParser parser = new OracleStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement statement = statementList.get(0);
print(statementList);
Assert.assertEquals(1, statementList.size());
Assert.assertEquals("CREATE TABLE ACT_HI_PROCINST (" + "\n\tID_ NVARCHAR2(64) NOT NULL," + "\n\tPROC_INST_ID_ NVARCHAR2(64) NOT NULL," + "\n\tBUSINESS_KEY_ NVARCHAR2(255)," + "\n\tPROC_DEF_ID_ NVARCHAR2(64) NOT NULL," + "\n\tSTART_TIME_ TIMESTAMP(6) NOT NULL," + "\n\tEND_TIME_ TIMESTAMP(6)," + "\n\tDURATION_ NUMBER(19, 0)," + "\n\tSTART_USER_ID_ NVARCHAR2(255)," + "\n\tSTART_ACT_ID_ NVARCHAR2(255)," + "\n\tEND_ACT_ID_ NVARCHAR2(255)," + "\n\tSUPER_PROCESS_INSTANCE_ID_ NVARCHAR2(64)," + "\n\tDELETE_REASON_ NVARCHAR2(2000)," + "\n\tPRIMARY KEY (ID_)," + "\n\tUNIQUE (PROC_INST_ID_)" + "\n)", SQLUtils.toSQLString(statement, JdbcConstants.ORACLE));
OracleSchemaStatVisitor visitor = new OracleSchemaStatVisitor();
statement.accept(visitor);
System.out.println("Tables : " + visitor.getTables());
System.out.println("fields : " + visitor.getColumns());
System.out.println("coditions : " + visitor.getConditions());
System.out.println("relationships : " + visitor.getRelationships());
System.out.println("orderBy : " + visitor.getOrderByColumns());
Assert.assertEquals(1, visitor.getTables().size());
Assert.assertEquals(12, visitor.getColumns().size());
Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("ACT_HI_PROCINST", "ID_")));
}
use of com.alibaba.druid.sql.dialect.oracle.visitor.OracleSchemaStatVisitor in project druid by alibaba.
the class OracleCreateTableTest18 method test_types.
public void test_types() throws Exception {
//
String sql = //
" CREATE TABLE \"SONAR\".\"AUTHORS\" " + //
" ( \"ID\" NUMBER(38,0) NOT NULL ENABLE, " + //
" \"PERSON_ID\" NUMBER(38,0) NOT NULL ENABLE, " + //
" \"LOGIN\" VARCHAR2(100 BYTE), " + //
" \"CREATED_AT\" TIMESTAMP (6), " + //
" \"UPDATED_AT\" TIMESTAMP (6), " + //
" PRIMARY KEY (\"ID\")" + //
" USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS " + //
" TABLESPACE \"USERS\" ENABLE" + //
" ) SEGMENT CREATION DEFERRED " + //
" PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 " + //
" NOCOMPRESS LOGGING" + " TABLESPACE \"USERS\" ;";
OracleStatementParser parser = new OracleStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement statement = statementList.get(0);
print(statementList);
Assert.assertEquals(1, statementList.size());
Assert.assertEquals(//
"CREATE TABLE \"SONAR\".\"AUTHORS\" (" + //
"\n\t\"ID\" NUMBER(38, 0) NOT NULL ENABLE," + //
"\n\t\"PERSON_ID\" NUMBER(38, 0) NOT NULL ENABLE," + //
"\n\t\"LOGIN\" VARCHAR2(100 BYTE)," + //
"\n\t\"CREATED_AT\" TIMESTAMP(6)," + //
"\n\t\"UPDATED_AT\" TIMESTAMP(6)," + "\n\tPRIMARY KEY (\"ID\")" + //
"\n\tUSING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS TABLESPACE \"USERS\" ENABLE" + "\n)" + "\nPCTFREE 10" + "\nINITRANS 1" + "\nMAXTRANS 255" + "\nNOCOMPRESS" + "\nLOGGING" + //
"\nTABLESPACE \"USERS\"", SQLUtils.toSQLString(statement, JdbcConstants.ORACLE));
OracleSchemaStatVisitor visitor = new OracleSchemaStatVisitor();
statement.accept(visitor);
System.out.println("Tables : " + visitor.getTables());
System.out.println("fields : " + visitor.getColumns());
System.out.println("coditions : " + visitor.getConditions());
System.out.println("relationships : " + visitor.getRelationships());
System.out.println("orderBy : " + visitor.getOrderByColumns());
Assert.assertEquals(1, visitor.getTables().size());
Assert.assertEquals(5, visitor.getColumns().size());
Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("SONAR.AUTHORS", "ID")));
}
use of com.alibaba.druid.sql.dialect.oracle.visitor.OracleSchemaStatVisitor in project druid by alibaba.
the class OracleAlterTableTest3 method test_0.
public void test_0() throws Exception {
//
String sql = //
"alter table WRH$_ROWCACHE_SUMMARY split partition WRH$_ROWCAC_1870432296_13862 " + //
" at (1870432296,13910) " + //
" into (partition WRH$_ROWCAC_1870432296_13862 tablespace SYSAUX, partition WRH$_ROWCAC_1870432296_13910 tablespace SYSAUX" + //
") " + " update indexes";
OracleStatementParser parser = new OracleStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement statemen = statementList.get(0);
print(statementList);
Assert.assertEquals(1, statementList.size());
OracleSchemaStatVisitor visitor = new OracleSchemaStatVisitor();
statemen.accept(visitor);
System.out.println("Tables : " + visitor.getTables());
System.out.println("fields : " + visitor.getColumns());
System.out.println("coditions : " + visitor.getConditions());
System.out.println("relationships : " + visitor.getRelationships());
System.out.println("orderBy : " + visitor.getOrderByColumns());
Assert.assertEquals(1, visitor.getTables().size());
Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("WRH$_ROWCACHE_SUMMARY")));
Assert.assertEquals(0, visitor.getColumns().size());
// Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("pivot_table", "*")));
// Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("pivot_table", "YEAR")));
// Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("pivot_table", "order_mode")));
}
Aggregations