常用的AST节点主要有三种类型:SQLObject、SQLExpr、SQLStatement;
其中最常使用的就是 SQLStatement ,其子类常见的有DruidSelectStatement、DruidInsertStatement、DruidUpdateStatement等。今天就来说说SQLStatement。
最常用的Statement当然是SELECT/UPDATE/DELETE/INSERT,它们是
class SQLSelectStatement implements SQLStatement {
SQLSelect select;
}
class SQLUpdateStatement implements SQLStatement {
SQLExprTableSource tableSource;
List<SQLUpdateSetItem> items;
SQLExpr where;
}
class SQLDeleteStatement implements SQLStatement {
SQLTableSource tableSource;
SQLExpr where;
}
class SQLInsertStatement implements SQLStatement {
SQLExprTableSource tableSource;
List<SQLExpr> columns;
SQLSelect query;
}
接下来看一下SQLSelect,SQLSelect包含一个SQLSelectQuery,都是组成的关系。SQLSelectQuery有主要的两个派生类,分别是SQLSelectQueryBlock和SQLUnionQuery