-
Notifications
You must be signed in to change notification settings - Fork 8.6k
SchemaStatVisitor_RelationShip
高铁 edited this page Feb 15, 2017
·
2 revisions
String dbType = JdbcConstants.ORACLE; // JdbcConstants.MYSQL/JdbcConstants.SQL_SERVER
String sql = "select a.id, b.name from table1 a inner join table2 b on a.id = b.id";
SQLStatementParser parser = SQLParserUtils.createSQLStatementParser(sql, dbType);
SQLStatement stmt = parser.parseStatementList().get(0);
SchemaStatVisitor statVisitor = SQLUtils.createSchemaStatVisitor(dbType);
stmt.accept(statVisitor);
Set<TableStat.Relationship> relationships = statVisitor.getRelationships();
for (TableStat.Relationship relationship : relationships) {
System.out.println(relationship); // table1.id = table2.id
}