use of com.alibaba.druid.sql.dialect.oracle.visitor.OracleSchemaStatVisitor in project druid by alibaba.
the class OracleExplainTest method test_0.
public void test_0() throws Exception {
//
String sql = "EXPLAIN PLAN SET STATEMENT_ID='PLUS19628905' FOR select * from( select row_.*, rownum rownum_ from( SELECT h.id taskId, t.id tradeId, t.OUT_ORDER_ID orderId, t.SELLER_SEQ sellerSeq, t.BUYER_SEQ buyerSeq, h.RECORD_TYPE recordType, t.SELLER_LOGIN_ID sellerLoginId, t.SELLER_ADMIN_SEQ sellerAdminSeq, h.GMT_CREATE gmtTaskCreate, h.GMT_MODIFIED gmtTaskModified, h.GMT_FETCH_TASK gmtFetchTask, h.GMT_FINISH_TASK gmtFinishTask, h.STATUS status, h.OWNER owner FROM HT_TASK_TRADE_HISTORY h, escrow_trade t WHERE h.TRADE_ID= t.ID and h.OWNER='zhoufei.zhangzf' and h.STATUS in('running') ORDER BY h.TASK_FLOW_LEVEL, t.GMT_CREATE, h.GMT_MODIFIED DESC) row_ where rownum<= 100) where rownum_>= 80";
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(0, visitor.getTables().size());
// Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("\"DUAL\"")));
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")));
}
use of com.alibaba.druid.sql.dialect.oracle.visitor.OracleSchemaStatVisitor in project druid by alibaba.
the class OracleCreateIndexTest1 method test_0.
public void test_0() throws Exception {
//
String sql = "create index PFS_PACKAGE_SAMPLE_PID_IND on PFS_PACKAGE_SAMPLE(PACKAGE_ID) tablespace appindx1m";
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("PFS_PACKAGE_SAMPLE")));
Assert.assertEquals(1, 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 OracleCreateIndexTest3 method test_0.
public void test_0() throws Exception {
//
String sql = "create index PRODUCT_ADDITION_NCID_IND on PRODUCT_ADDITION(NEW_CLUSTER_ID,GMT_LAST_FEEDBACK) tablespace APPINDX4M online parallel 4";
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("PRODUCT_ADDITION")));
Assert.assertEquals(2, visitor.getColumns().size());
Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("PRODUCT_ADDITION", "NEW_CLUSTER_ID")));
Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("PRODUCT_ADDITION", "GMT_LAST_FEEDBACK")));
// 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 OracleCreateIndexTest4 method test_0.
public void test_0() throws Exception {
//
String sql = //
" CREATE UNIQUE INDEX \"SONAR\".\"UNIQ_AUTHOR_LOGINS\" ON \"SONAR\".\"AUTHORS\" (\"LOGIN\") " + //
" PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS " + " TABLESPACE \"USERS\" ;";
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("SONAR.AUTHORS")));
Assert.assertEquals(1, visitor.getColumns().size());
Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("SONAR.AUTHORS", "LOGIN")));
// 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 OracleCreateProcedureTest1 method test_0.
public void test_0() throws Exception {
String sql = "CREATE OR REPLACE PROCEDURE p (" + " dept_no NUMBER" + ") AS " + "BEGIN" + " DELETE FROM dept_temp" + " WHERE department_id = dept_no;" + " " + " IF SQL%FOUND THEN" + " DBMS_OUTPUT.PUT_LINE (" + " 'Delete succeeded for department number ' || dept_no" + " );" + " ELSE" + " DBMS_OUTPUT.PUT_LINE ('No department number ' || dept_no);" + " END IF;" + "END;" + "/" + "BEGIN" + " p(270);" + " p(400);" + //
"END;";
OracleStatementParser parser = new OracleStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
print(statementList);
Assert.assertEquals(3, statementList.size());
OracleSchemaStatVisitor visitor = new OracleSchemaStatVisitor();
for (SQLStatement statement : statementList) {
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.assertTrue(visitor.getTables().containsKey(new TableStat.Name("dept_temp")));
// Assert.assertEquals(7, visitor.getColumns().size());
Assert.assertEquals(2, visitor.getConditions().size());
Assert.assertEquals(1, visitor.getRelationships().size());
// Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("employees", "salary")));
}
Aggregations