feat: update alter and drop statements (#94)

* feat: add UNIQUE keyword

* feat: support ifExist, addConstraint, dropConstraint and addUnique of alter table statement

* feat: support ifExist, addConstraint, dropConstraint and addUnique of alter table statement

* tests: add tests of alter statements

* docs: add comments for sql syntax

* build: optimize promote of build/antlr4

* ci: add max_old_space_size

* ci: add max_old_space_size

* ci: update tests script
This commit is contained in:
Ziv
2023-05-17 10:00:35 +08:00
committed by GitHub
parent 10645087de
commit fbee70cde5
15 changed files with 4341 additions and 3802 deletions

View File

@ -265,6 +265,7 @@ CATALOGS: 'CATALOGS';
VIEWS: 'VIEWS';
JARS: 'JARS';
PRIMARY: 'PRIMARY';
UNIQUE: 'UNIQUE';
KEY: 'KEY';
PERIOD: 'PERIOD';
SYSTEM_TIME: 'SYSTEM_TIME';

View File

@ -277,19 +277,37 @@ jarFileName
;
// Alter statements
// Just for simple alter table statements,
// it only includes rename, set key, add constraint, drop constraint, add unique
alterTable
: ALTER TABLE uid (renameDefinition | setKeyValueDefinition)
: ALTER TABLE ifExists? uid (renameDefinition | setKeyValueDefinition | addConstraint | dropConstraint | addUnique)
;
renameDefinition
: RENAME TO uid
: RENAME uid? TO uid
;
setKeyValueDefinition
: SET tablePropertyList
;
addConstraint
: ADD CONSTRAINT constraintName PRIMARY KEY columnNameList notForced?
;
dropConstraint
: DROP CONSTRAINT constraintName
;
addUnique
: ADD UNIQUE columnNameList
;
notForced
: NOT ENFORCED
;
alertView
: ALTER VIEW uid (renameDefinition | AS queryStatement)
;