use of com.alibaba.druid.sql.dialect.oracle.visitor.OracleSchemaStatVisitor in project druid by alibaba.
the class OracleCreateTableTest4 method test_0.
public void test_0() throws Exception {
//
String sql = "create table tbd_qi_xiaq_100961 tablespace tbd_data as select * /*1*/from product where company_id=10239004 ";
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(2, visitor.getTables().size());
Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("product")));
Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("tbd_qi_xiaq_100961")));
Assert.assertEquals(2, 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")));
}
use of com.alibaba.druid.sql.dialect.oracle.visitor.OracleSchemaStatVisitor in project druid by alibaba.
the class OracleCreateTableTest40 method test_types.
public void test_types() throws Exception {
//
String sql = "CREATE TABLE customers_part (" + " customer_id NUMBER(6)," + " cust_first_name VARCHAR2(20)," + " cust_last_name VARCHAR2(20)," + " nls_territory VARCHAR2(30)," + " credit_limit NUMBER(9,2)) " + " PARTITION BY RANGE (credit_limit)" + " SUBPARTITION BY LIST (nls_territory)" + " SUBPARTITION TEMPLATE " + " (SUBPARTITION east VALUES " + " ('CHINA', 'JAPAN', 'INDIA', 'THAILAND')," + " SUBPARTITION west VALUES " + " ('AMERICA', 'GERMANY', 'ITALY', 'SWITZERLAND')," + " SUBPARTITION other VALUES (DEFAULT))" + " (PARTITION p1 VALUES LESS THAN (1000)," + " PARTITION p2 VALUES LESS THAN (2500)," + " PARTITION p3 VALUES LESS THAN (MAXVALUE));";
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 customers_part (" + "\n\tcustomer_id NUMBER(6)," + "\n\tcust_first_name VARCHAR2(20)," + "\n\tcust_last_name VARCHAR2(20)," + "\n\tnls_territory VARCHAR2(30)," + "\n\tcredit_limit NUMBER(9, 2)" + "\n)" + "\nPARTITION BY RANGE (credit_limit)" + "\nSUBPARTITION BY HASH (nls_territory)" + "\n\tSUBPARTITION TEMPLATE (" + "\n\t\tSUBPARTITION east VALUES ('CHINA', 'JAPAN', 'INDIA', 'THAILAND')," + "\n\t\tSUBPARTITION west VALUES ('AMERICA', 'GERMANY', 'ITALY', 'SWITZERLAND')," + "\n\t\tSUBPARTITION other VALUES (DEFAULT)" + "\n\t)" + "\n(" + "\n\tPARTITION p1 VALUES LESS THAN (1000)," + "\n\tPARTITION p2 VALUES LESS THAN (2500)," + "\n\tPARTITION p3 VALUES LESS THAN (MAXVALUE)" + //
"\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(5, visitor.getColumns().size());
Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("customers_part", "customer_id")));
}
use of com.alibaba.druid.sql.dialect.oracle.visitor.OracleSchemaStatVisitor in project druid by alibaba.
the class OracleCreateTableTest5 method test_0.
public void test_0() throws Exception {
//
String sql = "CREATE GLOBAL TEMPORARY TABLE \"SYS\".\"SYS_TEMP_0FD9D670A_93E068F3\" (\"C0\" VARCHAR2(30),\"C1\" VARCHAR2(27) ) " + "IN_MEMORY_METADATA CURSOR_SPECIFIC_SEGMENT STORAGE (OBJNO 4254951178 )";
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("SYS.SYS_TEMP_0FD9D670A_93E068F3")));
Assert.assertEquals(2, visitor.getColumns().size());
Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("SYS.SYS_TEMP_0FD9D670A_93E068F3", "C0")));
Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("SYS.SYS_TEMP_0FD9D670A_93E068F3", "C1")));
// Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("pivot_table", "YEAR")));
// Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("pivot_table", "order_mode")));
}
use of com.alibaba.druid.sql.dialect.oracle.visitor.OracleSchemaStatVisitor in project druid by alibaba.
the class OracleCreateTableTest6 method test_0.
public void test_0() throws Exception {
//
String sql = "CREATE GLOBAL TEMPORARY TABLE \"SYS\".\"SYS_TEMP_0FD9D66FD_93E068F3\" (\"C0\" NUMBER,\"C1\" NUMBER ) IN_MEMORY_METADATA CURSOR_SPECIFIC_SEGMENT STORAGE (OBJNO 4254951165 ) NOPARALLEL";
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("SYS.SYS_TEMP_0FD9D66FD_93E068F3")));
Assert.assertEquals(2, visitor.getColumns().size());
Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("SYS.SYS_TEMP_0FD9D66FD_93E068F3", "C0")));
Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("SYS.SYS_TEMP_0FD9D66FD_93E068F3", "C1")));
// Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("pivot_table", "order_mode")));
}
use of com.alibaba.druid.sql.dialect.oracle.visitor.OracleSchemaStatVisitor in project druid by alibaba.
the class OracleCreateTableTest9 method test_0.
public void test_0() throws Exception {
//
String sql = //
"CREATE GLOBAL TEMPORARY TABLE \"ESCROW\".\"RUPD$_HT_TASK_TRADE_HISTOR\" (" + //
"\"ID\" NUMBER, " + //
"dmltype$$ varchar2(1), " + //
"snapid integer, " + //
"change_vector$$ raw(255)" + ") ON COMMIT PRESERVE ROWS";
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("ESCROW.RUPD$_HT_TASK_TRADE_HISTOR")));
Assert.assertEquals(4, visitor.getColumns().size());
Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("ESCROW.RUPD$_HT_TASK_TRADE_HISTOR", "ID")));
Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("ESCROW.RUPD$_HT_TASK_TRADE_HISTOR", "dmltype$$")));
Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("ESCROW.RUPD$_HT_TASK_TRADE_HISTOR", "snapid")));
Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("ESCROW.RUPD$_HT_TASK_TRADE_HISTOR", "change_vector$$")));
// Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("pivot_table", "order_mode")));
}
Aggregations