提交 169a43e6 编写于 作者: T terrymanu

for #2084, add dml for sqlserver

上级 093f4880
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
grammar DMLStatement;
import Symbol, Keyword, SQLServerKeyword, Literals, BaseRule;
insert
: INSERT INTO tableName (AS? alias)? (insertValuesClause | insertSelectClause)
;
insertValuesClause
: columnNames? VALUES assignmentValues (COMMA_ assignmentValues)*
;
insertSelectClause
: columnNames? select
;
update
: UPDATE tableReferences setAssignmentsClause whereClause?
;
assignment
: columnName EQ_ assignmentValue
;
setAssignmentsClause
: SET assignment (COMMA_ assignment)*
;
assignmentValues
: LP_ assignmentValue (COMMA_ assignmentValue)* RP_
| LP_ RP_
;
assignmentValue
: expr | DEFAULT
;
delete
: DELETE (singleTableClause_ | multipleTablesClause_) whereClause?
;
singleTableClause_
: FROM? LP_? tableName RP_? (AS? alias)?
;
multipleTablesClause_
: multipleTableNames_ FROM tableReferences | FROM multipleTableNames_ USING tableReferences
;
multipleTableNames_
: tableName DOT_ASTERISK_? (COMMA_ tableName DOT_ASTERISK_?)*
;
select
: unionClause_
;
unionClause_
: selectClause (UNION (ALL | DISTINCT)? selectClause)*
;
selectClause
: SELECT duplicateSpecification? selectItems fromClause? whereClause? groupByClause? havingClause? orderByClause?
;
duplicateSpecification
: ALL | DISTINCT
;
selectItems
: (unqualifiedShorthand | selectItem) (COMMA_ selectItem)*
;
selectItem
: (columnName | expr) (AS? alias)? | qualifiedShorthand
;
alias
: identifier_ | STRING_
;
unqualifiedShorthand
: ASTERISK_
;
qualifiedShorthand
: identifier_ DOT_ASTERISK_
;
fromClause
: FROM tableReferences
;
tableReferences
: tableReference (COMMA_ tableReference)*
;
tableReference
: (tableFactor joinedTable)+ | tableFactor joinedTable*
;
tableFactor
: tableName (AS? alias)? | subquery columnNames? | LP_ tableReferences RP_
;
joinedTable
: NATURAL? ((INNER | CROSS)? JOIN) tableFactor joinSpecification?
| NATURAL? (LEFT | RIGHT | FULL) OUTER? JOIN tableFactor joinSpecification?
;
joinSpecification
: ON expr | USING columnNames
;
whereClause
: WHERE expr
;
groupByClause
: GROUP BY orderByItem (COMMA_ orderByItem)*
;
havingClause
: HAVING expr
;
subquery
: LP_ unionClause_ RP_ AS? alias?
;
......@@ -17,7 +17,7 @@
grammar SQLServerStatement;
import Symbol, Comments, DDLStatement, TCLStatement, DCLStatement;
import Symbol, Comments, DMLStatement, DDLStatement, TCLStatement, DCLStatement;
execute
: (createIndex
......
......@@ -25,6 +25,11 @@
<sql-statement-rule context="alterIndex" sql-statement-class="org.apache.shardingsphere.core.parse.antlr.sql.statement.ddl.DDLStatement" extractor-rule-refs="table, index" />
<sql-statement-rule context="dropIndex" sql-statement-class="org.apache.shardingsphere.core.parse.antlr.sql.statement.ddl.DDLStatement" extractor-rule-refs="table, index" />
<sql-statement-rule context="insert" sql-statement-class="org.apache.shardingsphere.core.parse.antlr.sql.statement.dml.InsertStatement" extractor-rule-refs="table, columns, insertColumns, insertValues" />
<sql-statement-rule context="update" sql-statement-class="org.apache.shardingsphere.core.parse.antlr.sql.statement.dml.UpdateStatement" extractor-rule-refs="tableReferences, columns, setAssignments, where, predicate" />
<sql-statement-rule context="delete" sql-statement-class="org.apache.shardingsphere.core.parse.antlr.sql.statement.dml.DeleteStatement" extractor-rule-refs="tables, columns, where, predicate" />
<sql-statement-rule context="select" sql-statement-class="org.apache.shardingsphere.core.parse.antlr.sql.statement.dml.SelectStatement" extractor-rule-refs="tableReferences, columns, selectItems, subqueryPredicate, where, predicate, groupBy, orderBy" optimizer-class="org.apache.shardingsphere.core.parse.antlr.optimizer.select.SelectOptimizer" />
<sql-statement-rule context="setTransaction" sql-statement-class="org.apache.shardingsphere.core.parse.antlr.sql.statement.tcl.SetTransactionStatement" />
<sql-statement-rule context="setImplicitTransactions" sql-statement-class="org.apache.shardingsphere.core.parse.antlr.sql.statement.tcl.SetAutoCommitStatement" extractor-rule-refs="setImplicitTransactions" />
<sql-statement-rule context="beginTransaction" sql-statement-class="org.apache.shardingsphere.core.parse.antlr.sql.statement.tcl.BeginTransactionStatement" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册