Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
c290c62a
Shardingsphere
项目概览
apache
/
Shardingsphere
通知
56
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Shardingsphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c290c62a
编写于
9月 09, 2018
作者:
C
codefairy08
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
split sqlserver ddl rule
fix test bug
上级
1356b81b
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
763 addition
and
0 deletion
+763
-0
sharding-jdbc-ddl-parser/src/main/antlr4/imports/SQLServerBase.g4
...-jdbc-ddl-parser/src/main/antlr4/imports/SQLServerBase.g4
+90
-0
sharding-jdbc-ddl-parser/src/main/antlr4/imports/SQLServerKeyword.g4
...bc-ddl-parser/src/main/antlr4/imports/SQLServerKeyword.g4
+4
-0
sharding-jdbc-ddl-parser/src/main/antlr4/io/shardingsphere/parser/antlr/sqlserver/SQLServerAlterTable.g4
...rdingsphere/parser/antlr/sqlserver/SQLServerAlterTable.g4
+371
-0
sharding-jdbc-ddl-parser/src/main/antlr4/io/shardingsphere/parser/antlr/sqlserver/SQLServerCreateTable.g4
...dingsphere/parser/antlr/sqlserver/SQLServerCreateTable.g4
+298
-0
未找到文件。
sharding-jdbc-ddl-parser/src/main/antlr4/imports/SQLServerBase.g4
0 → 100644
浏览文件 @
c290c62a
grammar SQLServerBase;
import SQLServerKeyword,Keyword,Symbol,BaseRule,DataType;
dataType:
typeName
(
LEFT_PAREN
(
(NUMBER ( COMMA NUMBER )?)
| MAX
|((CONTENT | DOCUMENT)? xmlSchemaCollection)
)
RIGHT_PAREN
)?
;
privateExprOfDb:
windowedFunction
|atTimeZoneExpr
|castExpr
|convertExpr
;
atTimeZoneExpr:
ID (WITH TIME ZONE)? STRING
;
castExpr:
CAST LEFT_PAREN expr AS dataType (LEFT_PAREN NUMBER RIGHT_PAREN )? RIGHT_PAREN
;
convertExpr:
CONVERT ( dataType (LEFT_PAREN NUMBER RIGHT_PAREN )? COMMA expr (COMMA NUMBER)?)
;
windowedFunction:
functionCall overClause
;
overClause:
OVER
LEFT_PAREN
partitionByClause?
orderByClause?
rowRangeClause?
RIGHT_PAREN
;
partitionByClause:
PARTITION BY expr (COMMA expr)*
;
orderByClause:
ORDER BY orderByExpr (COMMA orderByExpr)*
;
orderByExpr:
expr (COLLATE collationName)? (ASC | DESC)?
;
rowRangeClause:
(ROWS | RANGE) windowFrameExtent
;
windowFrameExtent:
windowFramePreceding
| windowFrameBetween
;
windowFrameBetween:
BETWEEN windowFrameBound AND windowFrameBound
;
windowFrameBound:
windowFramePreceding
| windowFrameFollowing
;
windowFramePreceding:
(UNBOUNDED PRECEDING)
| NUMBER PRECEDING
| CURRENT ROW
;
windowFrameFollowing:
UNBOUNDED FOLLOWING
| NUMBER FOLLOWING
| CURRENT ROW
;
\ No newline at end of file
sharding-jdbc-ddl-parser/src/main/antlr4/imports/SQLServerKeyword.g4
浏览文件 @
c290c62a
...
...
@@ -292,3 +292,7 @@ WEEKS: W E E K S;
YEAR: Y E A R;
YEARS: Y E A R S;
FILETABLE_NAMESPACE: F I L E T A B L E UL_ N A M E S P A C E;
SPLIT: S P L I T;
DISTRIBUTION: D I S T R I B U T I O N;
ROUND_ROBIN:R O U N D UL_ R O B I N;
REPLICATE: R E P L I C A T E;
sharding-jdbc-ddl-parser/src/main/antlr4/io/shardingsphere/parser/antlr/sqlserver/SQLServerAlterTable.g4
0 → 100644
浏览文件 @
c290c62a
grammar SQLServerAlterTable;
import SQLServerKeyword, DataType, Keyword, SQLServerBase,BaseRule,Symbol;
alterTable:
alterTableOp
(alterColumn
|addColumn
|alterDrop
|alterCheckConstraint
|alterTrigger
|alterTracking
|alterSwitch
|alterSet
|alterRebuild
|mergeOrSplit
|tableOption
|fileTableOption
|stretchConfiguration)
;
alterTableOp:
ALTER TABLE tableName
;
alterColumn:
ALTER COLUMN columnName
(
dataType
(
(COLLATE collationName)
|( NULL | NOT NULL )
|( SPARSE )
)*
| ((ADD | DROP) ( ROWGUIDCOL | PERSISTED | NOT FOR REPLICATION | SPARSE | HIDDEN_))
| ((ADD | DROP) MASKED (WITH LEFT_PAREN FUNCTION EQ_OR_ASSIGN STRING RIGHT_PAREN )?)
)
(WITH LEFT_PAREN ONLINE EQ_OR_ASSIGN ON | OFF RIGHT_PAREN)?
;
addColumn:
(WITH (CHECK | NOCHECK))?
ADD
(
(alterColumnAddOption (COMMA alterColumnAddOption)*)
|(
(columnNameGeneratedClause COMMA periodClause)
|(periodClause COMMA columnNameGeneratedClause)
)
)
;
periodClause:
PERIOD FOR SYSTEM_TIME LEFT_PAREN columnName
COMMA columnName RIGHT_PAREN
;
alterColumnAddOption:
columnDefinition
|constraintForColumn
| computedColumnDefinition
| tableConstraint
| columnSetDefinition
| tableIndex
| columnIndex
;
constraintForColumn:
columnConstraint FOR columnName
;
columnDefinition:
columnName dataType
columnConstraint?
collateClause?
(NOT? NULL)?
;
columnConstraint :
(CONSTRAINT constraintName )?
DEFAULT simpleExpr
;
computedColumnDefinition :
columnName AS expr
(PERSISTED( NOT NULL )?)?
columnConstraint?
;
tableConstraint:
(CONSTRAINT constraintName )?
(
tablePrimaryConstraint
| tableForeignKeyConstraint
| (CHECK expr)
)
;
tablePrimaryConstraint:
primaryKeyUnique (CLUSTERED | NONCLUSTERED)?
(
columnNameWithSortsWithParen
|hashWithBucket
)
;
hashWithBucket:
HASH columnList withBucket
;
withBucket:
WITH LEFT_PAREN BUCKET_COUNT EQ_OR_ASSIGN NUMBER RIGHT_PAREN
;
primaryKeyUnique:
(PRIMARY KEY)
| UNIQUE
;
columnNameWithSortsWithParen:
LEFT_PAREN columnNameWithSort (COMMA columnNameWithSort)* RIGHT_PAREN
;
columnNameWithSort:
columnName ( ASC | DESC )?
;
tableForeignKeyConstraint:
(FOREIGN KEY)? columnList
REFERENCES tableName columnList
;
columnSetDefinition :
columnSetName ID COLUMN_SET FOR ALL_SPARSE_COLUMNS
;
columnIndex:
INDEX indexName
( CLUSTERED | NONCLUSTERED )?
HASH withBucket
;
columnNameGeneratedClause:
columnNameGenerated
DEFAULT simpleExpr (WITH VALUES)? COMMA
columnNameGenerated
;
columnNameGenerated:
columnName typeName GENERATED ALWAYS AS ROW START
HIDDEN_? (NOT NULL)? (CONSTRAINT constraintName)?
;
alterDrop:
DROP
(
alterTableDropConstraint
|alterTableDropColumn
|alterTableDropIndex
|(PERIOD FOR SYSTEM_TIME)
)
;
alterTableDropConstraint:
CONSTRAINT? (IF EXISTS)?
dropConstraintName (COMMA dropConstraintName)*
;
dropConstraintName:
constraintName dropConstraintWithClause?
;
dropConstraintWithClause:
WITH LEFT_PAREN dropConstraintOption ( COMMA dropConstraintOption)* RIGHT_PAREN
;
dropConstraintOption:
(
(MAXDOP EQ_OR_ASSIGN NUMBER )
| (ONLINE EQ_OR_ASSIGN ( ON | OFF ))
| (MOVE TO
( schemaName LEFT_PAREN columnName RIGHT_PAREN | fileGroup | STRING ) )
)
;
alterTableDropColumn:
COLUMN (IF EXISTS)? columnNames
;
alterTableDropIndex:
INDEX (IF EXISTS)?
indexName (COMMA indexName)*
;
alterCheckConstraint:
WITH? (CHECK | NOCHECK) CONSTRAINT
(ALL | (constraintName (COMMA constraintName)*))
;
alterTrigger:
(ENABLE| DISABLE) TRIGGER
(ALL | (triggerName ( COMMA triggerName)*))
;
alterTracking:
(ENABLE | DISABLE) CHANGE_TRACKING
(WITH LEFT_PAREN TRACK_COLUMNS_UPDATED EQ_OR_ASSIGN (ON | OFF) RIGHT_PAREN )?
;
alterSwitch:
SWITCH ( PARTITION expr )?
TO tableName
( PARTITION expr)?
( WITH LEFT_PAREN lowPriorityLockWait RIGHT_PAREN )?
;
alterSet:
SET
LEFT_PAREN
(
setFileStreamClause
|setSystemVersionClause
)
RIGHT_PAREN
;
setFileStreamClause:
FILESTREAM_ON EQ_OR_ASSIGN ( schemaName | fileGroup | STRING )
;
setSystemVersionClause:
SYSTEM_VERSIONING EQ_OR_ASSIGN
(
OFF
|alterSetOnClause
)
;
alterSetOnClause:
ON
(LEFT_PAREN
(HISTORY_TABLE EQ_OR_ASSIGN tableName)?
(COMMA? DATA_CONSISTENCY_CHECK EQ_OR_ASSIGN ( ON | OFF ))?
(COMMA? HISTORY_RETENTION_PERIOD EQ_OR_ASSIGN
(
INFINITE | (NUMBER (DAY | DAYS | WEEK | WEEKS | MONTH | MONTHS | YEAR | YEARS ))
)
)?
RIGHT_PAREN
)?
;
alterRebuild:
REBUILD
(
((PARTITION EQ_OR_ASSIGN ALL)? (WITH LEFT_PAREN rebuildOption ( COMMA rebuildOption)* RIGHT_PAREN ))
| (PARTITION EQ_OR_ASSIGN numberRange)? (WITH LEFT_PAREN singlePartitionRebuildOption (COMMA singlePartitionRebuildOption)* RIGHT_PAREN )?
)
;
fileTableOption :
((ENABLE | DISABLE) FILETABLE_NAMESPACE)
|(SET LEFT_PAREN FILETABLE_DIRECTORY EQ_OR_ASSIGN directoryName RIGHT_PAREN )
;
stretchConfiguration :
SET
LEFT_PAREN
REMOTE_DATA_ARCHIVE
(
(EQ_OR_ASSIGN ON LEFT_PAREN tableStretchOptions RIGHT_PAREN)
| (EQ_OR_ASSIGN OFF_WITHOUT_DATA_RECOVERY LEFT_PAREN MIGRATION_STATE EQ_OR_ASSIGN PAUSED RIGHT_PAREN)
| (LEFT_PAREN tableStretchOptions (COMMA )? RIGHT_PAREN)
)
RIGHT_PAREN
;
tableStretchOptions:
( FILTER_PREDICATE EQ_OR_ASSIGN ( NULL | functionCall ) COMMA )?
MIGRATION_STATE EQ_OR_ASSIGN ( OUTBOUND | INBOUND | PAUSED )
;
singlePartitionRebuildOption :
(SORT_IN_TEMPDB EQ_OR_ASSIGN ( ON | OFF ))
| (MAXDOP EQ_OR_ASSIGN NUMBER)
| compressionOption
| (ONLINE EQ_OR_ASSIGN (OFF |onLowPriorLockWait))
;
onLowPriorLockWait:
ON (LEFT_PAREN lowPriorityLockWait RIGHT_PAREN )?
;
lowPriorityLockWait:
WAIT_AT_LOW_PRIORITY LEFT_PAREN MAX_DURATION EQ_OR_ASSIGN NUMBER ( MINUTES )? COMMA
ABORT_AFTER_WAIT EQ_OR_ASSIGN ( NONE | SELF | BLOCKERS ) RIGHT_PAREN
;
rebuildOption:
(compressionOption (ON PARTITIONS LEFT_PAREN numberRange (COMMA numberRange)* RIGHT_PAREN))
| eqOnOffOption
| MAXDOP EQ_OR_ASSIGN NUMBER
| (ONLINE EQ_OR_ASSIGN (OFF | onLowPriorLockWait))
;
eqOnOffOption:
(
PAD_INDEX
|FILLFACTOR
|IGNORE_DUP_KEY
|STATISTICS_NORECOMPUTE
|ALLOW_ROW_LOCKS
|ALLOW_PAGE_LOCKS
|SORT_IN_TEMPDB
)eqOnOff
;
eqOnOff:
EQ_OR_ASSIGN ( ON | OFF )
;
compressionOption:
DATA_COMPRESSION EQ_OR_ASSIGN ( NONE | ROW | PAGE | COLUMNSTORE | COLUMNSTORE_ARCHIVE)
;
numberRange:
NUMBER (TO NUMBER)?
;
alterIndex:
ALTER INDEX indexName
typeName REBUILD
(NONCLUSTERED? WITH LEFT_PAREN BUCKET_COUNT EQ_OR_ASSIGN NUMBER RIGHT_PAREN)?
;
tableIndex:
INDEX indexName
(
indexNonClusterClause
|indexClusterClause
)
;
indexNonClusterClause:
NONCLUSTERED
(hashWithBucket | (columnNameWithSortsWithParen indexOnClause?))
;
indexOnClause:
(ON groupName)
| DEFAULT
;
indexClusterClause:
CLUSTERED COLUMNSTORE
(WITH COMPRESSION_DELAY EQ_OR_ASSIGN NUMBER MINUTES?)?
indexOnClause?
;
tableOption:
(SET LEFT_PAREN LOCK_ESCALATION EQ_OR_ASSIGN (AUTO | TABLE | DISABLE) RIGHT_PAREN)
|(MEMORY_OPTIMIZED EQ_OR_ASSIGN ON)
| (DURABILITY EQ_OR_ASSIGN (SCHEMA_ONLY | SCHEMA_AND_DATA))
| (SYSTEM_VERSIONING EQ_OR_ASSIGN ON ( LEFT_PAREN HISTORY_TABLE EQ_OR_ASSIGN tableName
(COMMA DATA_CONSISTENCY_CHECK EQ_OR_ASSIGN ( ON | OFF ) )? RIGHT_PAREN )?)
;
mergeOrSplit:
(SPLIT | MERGE) RANGE LEFT_PAREN simpleExpr RIGHT_PAREN
;
\ No newline at end of file
sharding-jdbc-ddl-parser/src/main/antlr4/io/shardingsphere/parser/antlr/sqlserver/SQLServer
DDL
.g4
→
sharding-jdbc-ddl-parser/src/main/antlr4/io/shardingsphere/parser/antlr/sqlserver/SQLServer
CreateTable
.g4
浏览文件 @
c290c62a
grammar SQLServer
DDL
;
import SQLServerKeyword, DataType, Keyword,
BaseRule,DDLBase,MySQLDQL,DQLBas
e,Symbol;
grammar SQLServer
CreateTable
;
import SQLServerKeyword, DataType, Keyword,
SQLServerBase,BaseRul
e,Symbol;
createTable:
createTableOpWithName
(
createMemoryTable
|createDiskTable
)
createTableHeader createTableBody
;
createTable
OpWithName
:
createTable
Header
:
CREATE TABLE tableName
;
create
DiskTable
:
create
TableBody
:
(AS FILETABLE)?
LEFT_PAREN
createTableDefinition (COMMA createTableDefinition)*
periodClause
?
(COMMA periodClause)
?
RIGHT_PAREN
(ON ( schemaName LEFT_PAREN columnName RIGHT_PAREN
| fileGroup
...
...
@@ -72,18 +68,6 @@ columnDefinitionOption:
|columnIndex
;
dataType:
typeName
(
LEFT_PAREN
(
(NUMBER ( COMMA NUMBER )?)
| MAX
|((CONTENT | DOCUMENT)? xmlSchemaCollection)
)
RIGHT_PAREN
)?
;
columnConstraint :
(CONSTRAINT constraintName )?
...
...
@@ -94,11 +78,28 @@ columnConstraint :
;
primaryKeyConstraint:
(PRIMARY KEY | UNIQUE) (CLUSTERED | NONCLUSTERED)?
(PRIMARY KEY | UNIQUE)
(diskTablePrimaryKeyConstraintOption | memoryTablePrimaryKeyConstraintOption)
;
diskTablePrimaryKeyConstraintOption:
(CLUSTERED | NONCLUSTERED)?
primaryKeyWithClause?
primaryKeyOnClause?
;
memoryTablePrimaryKeyConstraintOption:
CLUSTERED withBucket?
;
hashWithBucket:
HASH columnList withBucket
;
withBucket:
WITH LEFT_PAREN BUCKET_COUNT EQ_OR_ASSIGN NUMBER RIGHT_PAREN
;
primaryKeyWithClause:
WITH
((FILLFACTOR EQ_OR_ASSIGN NUMBER)
...
...
@@ -176,15 +177,25 @@ tableConstraint:
tablePrimaryConstraint:
primaryKeyUnique
(diskTablePrimaryConstraintOption | memoryTablePrimaryConstraintOption)
;
primaryKeyUnique:
(PRIMARY KEY)
| UNIQUE
;
diskTablePrimaryConstraintOption:
( CLUSTERED | NONCLUSTERED )?
columnNameWithSortsWithParen
primaryKeyWithClause?
primaryKeyOnClause?
;
primaryKeyUnique:
(PRIMARY KEY)
| UNIQUE
memoryTablePrimaryConstraintOption:
NONCLUSTERED
(columnNameWithSortsWithParen
| hashWithBucket)
;
columnNameWithSortsWithParen:
...
...
@@ -202,7 +213,8 @@ tableIndex:
(
((CLUSTERED | NONCLUSTERED )? columnNameWithSortsWithParen)
| (CLUSTERED COLUMNSTORE)
| (( NONCLUSTERED )? COLUMNSTORE columnList)
| (( NONCLUSTERED )? ((COLUMNSTORE columnList) | hashWithBucket))
| (CLUSTERED COLUMNSTORE (WITH LEFT_PAREN COMPRESSION_DELAY EQ_OR_ASSIGN (NUMBER MINUTES?) RIGHT_PAREN)?)
)
)
(WHERE expr)?
...
...
@@ -214,7 +226,7 @@ tableIndex:
| DEFAULT
)
)?
( FILESTREAM_ON ( groupName | schemaName | STRING )
)?
( FILESTREAM_ON ( groupName | schemaName | STRING ))?
)
;
...
...
@@ -237,6 +249,21 @@ tableOption:
|tableOptOption
;
tableOptOption :
(MEMORY_OPTIMIZED EQ_OR_ASSIGN ON)
| (DURABILITY EQ_OR_ASSIGN (SCHEMA_ONLY | SCHEMA_AND_DATA))
| (SYSTEM_VERSIONING EQ_OR_ASSIGN ON ( LEFT_PAREN HISTORY_TABLE EQ_OR_ASSIGN tableName
(COMMA DATA_CONSISTENCY_CHECK EQ_OR_ASSIGN ( ON | OFF ) )? RIGHT_PAREN )?)
;
dataWareHouseTableOption :
DISTRIBUTION EQ_OR_ASSIGN
(
(HASH LEFT_PAREN columnName RIGHT_PAREN)
| ROUND_ROBIN
| REPLICATE
)
;
tableStretchOptions:
( FILTER_PREDICATE EQ_OR_ASSIGN ( NULL | functionCall ) COMMA )?
MIGRATION_STATE EQ_OR_ASSIGN ( OUTBOUND | INBOUND | PAUSED )
...
...
@@ -268,365 +295,4 @@ partitionRange:
NUMBER TO NUMBER
;
createMemoryTable:
LEFT_PAREN
columnOption (COMMA columnOption)*
(COMMA periodClause)?
RIGHT_PAREN
(WITH LEFT_PAREN tableOptOption ( COMMA tableOptOption)* RIGHT_PAREN)?
;
columnOption:
columnOptDefinition
| (tableOptConstraint (COMMA tableOptConstraint)*)?
| tableIndex?
;
columnOptDefinition :
columnName dataType
columnOptDefinitionOpt*
;
columnOptDefinitionOpt:
(COLLATE collationName )
| (GENERATED ALWAYS AS ROW (START | END) HIDDEN_? )
| (NOT? NULL)
| ((CONSTRAINT constraintName )? DEFAULT expr )
| ( IDENTITY ( LEFT_PAREN NUMBER COMMA NUMBER RIGHT_PAREN ) )
| columnOptConstraint
| columnOptIndex
;
columnOptConstraint :
(CONSTRAINT constraintName )?
(
primaryKeyOptConstaint
| foreignKeyOptConstaint
| (CHECK LEFT_PAREN expr RIGHT_PAREN)
)
;
primaryKeyOptConstaint:
primaryKeyUnique
(
(NONCLUSTERED columnNameWithSortsWithParen)
| (NONCLUSTERED HASH WITH LEFT_PAREN BUCKET_COUNT EQ_OR_ASSIGN NUMBER RIGHT_PAREN)
)
;
foreignKeyOptConstaint:
(FOREIGN KEY )? REFERENCES tableName ( LEFT_PAREN columnName RIGHT_PAREN )?
;
tableOptConstraint:
( CONSTRAINT constraintName )?
(
(primaryKeyUnique
(
(NONCLUSTERED columnNameWithSortsWithParen)
| (NONCLUSTERED HASH columnList WITH LEFT_PAREN BUCKET_COUNT EQ_OR_ASSIGN NUMBER RIGHT_PAREN)
))
| (FOREIGN KEY columnList REFERENCES tableName columnList? )
| (CHECK LEFT_PAREN expr RIGHT_PAREN )
)
;
columnOptIndex:
INDEX indexName
(NONCLUSTERED? (HASH WITH LEFT_PAREN BUCKET_COUNT EQ_OR_ASSIGN NUMBER RIGHT_PAREN)? )
;
tableOptIndex :
INDEX indexName
(
( NONCLUSTERED ? HASH columnList WITH LEFT_PAREN BUCKET_COUNT EQ_OR_ASSIGN NUMBER RIGHT_PAREN )
| ( NONCLUSTERED ? columnNameWithSortsWithParen ( ON groupName | DEFAULT )? )
| (CLUSTERED COLUMNSTORE (WITH LEFT_PAREN COMPRESSION_DELAY EQ_OR_ASSIGN (NUMBER MINUTES?) RIGHT_PAREN)? ( ON groupName | DEFAULT )?)
)
;
tableOptOption :
(MEMORY_OPTIMIZED EQ_OR_ASSIGN ON)
| (DURABILITY EQ_OR_ASSIGN (SCHEMA_ONLY | SCHEMA_AND_DATA))
| (SYSTEM_VERSIONING EQ_OR_ASSIGN ON ( LEFT_PAREN HISTORY_TABLE EQ_OR_ASSIGN tableName
(COMMA DATA_CONSISTENCY_CHECK EQ_OR_ASSIGN ( ON | OFF ) )? RIGHT_PAREN )?)
;
privateExprOfDb:
windowedFunction
|atTimeZoneExpr
|castExpr
|convertExpr
;
atTimeZoneExpr:
ID (WITH TIME ZONE)? STRING
;
castExpr:
CAST LEFT_PAREN expr AS dataType (LEFT_PAREN NUMBER RIGHT_PAREN )? RIGHT_PAREN
;
convertExpr:
CONVERT ( dataType (LEFT_PAREN NUMBER RIGHT_PAREN )? COMMA expr (COMMA NUMBER)?)
;
windowedFunction:
functionCall overClause
;
overClause:
OVER
LEFT_PAREN
partitionByClause?
orderByClause?
rowRangeClause?
RIGHT_PAREN
;
partitionByClause:
PARTITION BY expr (COMMA expr)*
;
orderByClause:
ORDER BY orderByExpr (COMMA orderByExpr)*
;
orderByExpr:
expr (COLLATE collationName)? (ASC | DESC)?
;
rowRangeClause:
(ROWS | RANGE) windowFrameExtent
;
windowFrameExtent:
windowFramePreceding
| windowFrameBetween
;
windowFrameBetween:
BETWEEN windowFrameBound AND windowFrameBound
;
windowFrameBound:
windowFramePreceding
| windowFrameFollowing
;
windowFramePreceding:
(UNBOUNDED PRECEDING)
| NUMBER PRECEDING
| CURRENT ROW
;
windowFrameFollowing:
UNBOUNDED FOLLOWING
| NUMBER FOLLOWING
| CURRENT ROW
;
alterTable:
alterTableOp
(alterColumn
|addColumn
|alterDrop
|alterCheckConstraint
|alterTrigger
|alterTracking
|alterSwitch
|alterSet
|alterRebuild
|fileTableOption
|stretchConfiguration)
;
alterTableOp:
ALTER TABLE tableName
;
alterColumn:
ALTER COLUMN columnName
(
dataType
(
(COLLATE collationName)
|( NULL | NOT NULL )
|( SPARSE )
)*
| ((ADD | DROP) ( ROWGUIDCOL | PERSISTED | NOT FOR REPLICATION | SPARSE | HIDDEN_))
| ((ADD | DROP) MASKED (WITH LEFT_PAREN FUNCTION EQ_OR_ASSIGN STRING RIGHT_PAREN )?)
)
(WITH LEFT_PAREN ONLINE EQ_OR_ASSIGN ON | OFF RIGHT_PAREN)?
;
alterIndex:
ALTER INDEX indexName
typeName REBUILD
(NONCLUSTERED? WITH LEFT_PAREN BUCKET_COUNT EQ_OR_ASSIGN NUMBER RIGHT_PAREN)?
;
addColumn:
(WITH (CHECK | NOCHECK))?
ADD
(
(alterColumnAddOption (COMMA alterColumnAddOption)*)
|(
(columnNameGeneratedClause COMMA periodClause)
|(periodClause COMMA columnNameGeneratedClause)
)
)
;
alterColumnAddOption:
columnDefinition
| computedColumnDefinition
| tableConstraint
| columnSetDefinition
| columnIndex
;
columnNameGeneratedClause:
columnNameGenerated
DEFAULT simpleExpr (WITH VALUES)? COMMA
columnNameGenerated
;
columnNameGenerated:
columnName typeName GENERATED ALWAYS AS ROW START
HIDDEN_? (NOT NULL)? (CONSTRAINT constraintName)?
;
alterDrop:
DROP
(
alterTableDropConstraint
|alterTableDropColumn
|(PERIOD FOR SYSTEM_TIME)
)
;
alterTableDropConstraint:
CONSTRAINT? (IF EXISTS)?
dropConstraintName (COMMA dropConstraintName)
;
dropConstraintName:
constraintName dropConstraintWithClause?
;
dropConstraintWithClause:
WITH LEFT_PAREN dropConstraintOption ( COMMA dropConstraintOption)* RIGHT_PAREN
;
alterTableDropColumn:
COLUMN (IF EXISTS)?
columnName (COMMA columnName)*
;
dropConstraintOption:
(
(MAXDOP EQ_OR_ASSIGN NUMBER )
| (ONLINE EQ_OR_ASSIGN ( ON | OFF ))
| (MOVE TO
( schemaName LEFT_PAREN columnName RIGHT_PAREN | fileGroup | STRING ) )
)
;
alterTableOption:
SET LEFT_PAREN LOCK_ESCALATION EQ_OR_ASSIGN (AUTO | TABLE | DISABLE) RIGHT_PAREN
;
alterCheckConstraint:
WITH? (CHECK | NOCHECK) CONSTRAINT
(ALL | (constraintName (COMMA constraintName)*))
;
alterTrigger:
(ENABLE| DISABLE) TRIGGER
(ALL | (triggerName ( COMMA triggerName)*))
;
alterTracking:
(ENABLE | DISABLE) CHANGE_TRACKING
(WITH LEFT_PAREN TRACK_COLUMNS_UPDATED EQ_OR_ASSIGN (ON | OFF) RIGHT_PAREN )?
;
alterSwitch:
SWITCH ( PARTITION expr )?
TO tableName
( PARTITION expr)?
( WITH LEFT_PAREN lowPriorityLockWait RIGHT_PAREN )?
;
alterSet:
SET
LEFT_PAREN
( FILESTREAM_ON EQ_OR_ASSIGN
( schemaName | fileGroup | STRING ) )
| (SYSTEM_VERSIONING EQ_OR_ASSIGN
(
OFF
|alterSetOnClause
)
)
RIGHT_PAREN
;
alterSetOnClause:
ON
(LEFT_PAREN
HISTORY_TABLE EQ_OR_ASSIGN tableName
(COMMA DATA_CONSISTENCY_CHECK EQ_OR_ASSIGN ( ON | OFF ) )?
(COMMA HISTORY_RETENTION_PERIOD EQ_OR_ASSIGN
(
INFINITE | NUMBER (DAY | DAYS | WEEK | WEEKS | MONTH | MONTHS | YEAR | YEARS )
)
)?
RIGHT_PAREN
)?
;
alterRebuild:
REBUILD
(
((PARTITION EQ_OR_ASSIGN ALL)? ( WITH LEFT_PAREN rebuildOption ( COMMA rebuildOption)* RIGHT_PAREN ))
| ( PARTITION EQ_OR_ASSIGN numberRange (WITH LEFT_PAREN singlePartitionRebuildOption (COMMA singlePartitionRebuildOption)* RIGHT_PAREN )?)
)
;
fileTableOption :
((ENABLE | DISABLE) FILETABLE_NAMESPACE)
|(SET LEFT_PAREN FILETABLE_DIRECTORY EQ_OR_ASSIGN directoryName RIGHT_PAREN )
;
stretchConfiguration :
SET
LEFT_PAREN
REMOTE_DATA_ARCHIVE
(
(EQ_OR_ASSIGN ON LEFT_PAREN tableStretchOptions RIGHT_PAREN)
| (EQ_OR_ASSIGN OFF_WITHOUT_DATA_RECOVERY LEFT_PAREN MIGRATION_STATE EQ_OR_ASSIGN PAUSED RIGHT_PAREN)
| (LEFT_PAREN tableStretchOptions (COMMA )? RIGHT_PAREN)
)
RIGHT_PAREN
;
singlePartitionRebuildOption :
(SORT_IN_TEMPDB EQ_OR_ASSIGN ( ON | OFF ))
| (MAXDOP EQ_OR_ASSIGN NUMBER)
| (DATA_COMPRESSION EQ_OR_ASSIGN ( NONE | ROW | PAGE | COLUMNSTORE | COLUMNSTORE_ARCHIVE))
| (ONLINE EQ_OR_ASSIGN ( ON (LEFT_PAREN lowPriorityLockWait RIGHT_PAREN )?| OFF))
;
lowPriorityLockWait:
WAIT_AT_LOW_PRIORITY LEFT_PAREN MAX_DURATION EQ_OR_ASSIGN NUMBER ( MINUTES )? COMMA
ABORT_AFTER_WAIT EQ_OR_ASSIGN ( NONE | SELF | BLOCKERS ) RIGHT_PAREN
;
rebuildOption:
DATA_COMPRESSION EQ_OR_ASSIGN (COLUMNSTORE | COLUMNSTORE_ARCHIVE )
(ON PARTITIONS LEFT_PAREN numberRange (COMMA numberRange)* RIGHT_PAREN)
;
numberRange:
NUMBER (TO NUMBER)?
;
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录