use of com.alibaba.druid.sql.dialect.oracle.parser.OracleStatementParser in project druid by alibaba.
the class OracleCreateTableTest1 method test_0.
public void test_0() throws Exception {
//
String sql = "CREATE TABLE wl_track_task ( id NUMBER NOT NULL, gmt_modified DATE NOT NULL, gmt_create DATE NOT NULL, task_status VARCHAR2(8) NOT NULL, task_error_msg VARCHAR2(512), task_update_count NUMBER, logistics_no VARCHAR2(32) NOT NULL, logistics_type NUMBER NOT NULL ) tablespace escrow_data";
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("wl_track_task")));
Assert.assertEquals(8, 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.parser.OracleStatementParser in project druid by alibaba.
the class OracleCreateTableTest3 method test_0.
public void test_0() throws Exception {
//
String sql = "ALTER TABLE wl_ship_order modify ( forwarder_service NOT NULL , status NOT NULL )";
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("wl_ship_order")));
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.parser.OracleStatementParser in project druid by alibaba.
the class OracleCreateTableTest30 method test_types.
public void test_types() throws Exception {
//
String sql = //
"CREATE TABLE order_detail " + //
" (CONSTRAINT pk_od PRIMARY KEY (order_id, part_no), " + //
" order_id NUMBER " + //
" CONSTRAINT fk_oid " + //
" REFERENCES oe.orders(order_id), " + //
" part_no NUMBER " + //
" CONSTRAINT fk_pno " + //
" REFERENCES oe.product_information(product_id), " + //
" quantity NUMBER " + //
" CONSTRAINT nn_qty NOT NULL " + //
" CONSTRAINT check_qty CHECK (quantity > 0), " + //
" cost NUMBER " + " CONSTRAINT check_cost CHECK (cost > 0) ); ";
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 order_detail (" + //
"\n\tCONSTRAINT pk_od PRIMARY KEY (order_id, part_no)," + //
"\n\torder_id NUMBER" + //
"\n\t\tCONSTRAINT fk_oid REFERENCES oe.orders (order_id)," + //
"\n\tpart_no NUMBER" + //
"\n\t\tCONSTRAINT fk_pno REFERENCES oe.product_information (product_id)," + //
"\n\tquantity NUMBER" + //
"\n\t\tCONSTRAINT nn_qty NOT NULL" + //
"\n\t\tCONSTRAINT check_qty CHECK (quantity > 0)," + //
"\n\tcost NUMBER" + //
"\n\t\tCONSTRAINT check_cost CHECK (cost > 0)" + //
"\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(4, visitor.getColumns().size());
Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("order_detail", "order_id")));
}
use of com.alibaba.druid.sql.dialect.oracle.parser.OracleStatementParser in project druid by alibaba.
the class OracleCreateTableTest31 method test_types.
public void test_types() throws Exception {
//
String sql = //
"CREATE TABLE students (name person_name, age INTEGER," + //
" CHECK (name.first_name IS NOT NULL AND " + " name.last_name IS NOT NULL));";
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 students (" + "\n\tname person_name," + "\n\tage INTEGER," + "\n\tCHECK (name.first_name IS NOT NULL" + "\n\t\tAND name.last_name IS NOT NULL)" + //
"\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(4, visitor.getColumns().size());
Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("students", "name")));
}
use of com.alibaba.druid.sql.dialect.oracle.parser.OracleStatementParser in project druid by alibaba.
the class OracleCreateTableTest34 method test_types.
public void test_types() throws Exception {
//
String sql = "CREATE TABLE long_tab (pic_id NUMBER, long_pics LONG RAW);";
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 long_tab (" + //
"\n\tpic_id NUMBER," + //
"\n\tlong_pics LONG RAW" + //
"\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(2, visitor.getColumns().size());
Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("long_tab", "pic_id")));
Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("long_tab", "long_pics")));
}
Aggregations