diff --git a/sql/plsql/PlSqlLexer.g4 b/sql/plsql/PlSqlLexer.g4 index b73d5c444f..37978ecfdd 100644 --- a/sql/plsql/PlSqlLexer.g4 +++ b/sql/plsql/PlSqlLexer.g4 @@ -81,6 +81,7 @@ ANCESTOR : 'ANCESTOR'; ANCILLARY : 'ANCILLARY'; AND : 'AND'; AND_EQUAL : 'AND_EQUAL'; +ANNOTATIONS : 'ANNOTATIONS'; ANOMALY : 'ANOMALY'; ANSI_REARCH : 'ANSI_REARCH'; ANTIJOIN : 'ANTIJOIN'; diff --git a/sql/plsql/PlSqlParser.g4 b/sql/plsql/PlSqlParser.g4 index d12460ddb0..17114d61a3 100644 --- a/sql/plsql/PlSqlParser.g4 +++ b/sql/plsql/PlSqlParser.g4 @@ -3511,6 +3511,7 @@ table_properties | ROW ARCHIVAL | AS select_only_statement | FOR EXCHANGE WITH TABLE (schema_name '.')? table_name + | annotations_clause ; read_only_clause @@ -4991,6 +4992,7 @@ alter_table_properties | READ ONLY | READ WRITE | REKEY CHAR_STRING + | annotations_clause ; alter_table_partitioning @@ -5284,7 +5286,7 @@ modify_column_clauses ; modify_col_properties - : column_name datatype? (DEFAULT (ON NULL_)? expression)? (ENCRYPT encryption_spec | DECRYPT)? inline_constraint* lob_storage_clause? + : column_name datatype? (DEFAULT (ON NULL_)? expression)? (ENCRYPT encryption_spec | DECRYPT)? inline_constraint* lob_storage_clause? annotations_clause? //TODO alter_xmlschema_clause ; @@ -5456,7 +5458,7 @@ column_definition )? (DEFAULT (ON NULL_)? expression | identity_clause)? (ENCRYPT encryption_spec)? ( inline_constraint+ | inline_ref_constraint - )? + )? annotations_clause? ; column_collation_name @@ -7119,6 +7121,24 @@ xmlserialize_param_ident_part | INDENT (SIZE '=' concatenation)? ; +// Annotations + +annotations_clause + : ANNOTATIONS '(' annotations_list ')' + ; + +annotations_list + : ( + ADD (IF NOT EXISTS | OR REPLACE)? + | DROP (IF EXISTS)? + | REPLACE + )? annotation (',' annotations_list)* + ; + +annotation + : identifier CHAR_STRING? + ; + // SqlPlus sql_plus_command_no_semicolon diff --git a/sql/plsql/examples/alter_table.sql b/sql/plsql/examples/alter_table.sql index 4da01b5b60..c690d0251d 100644 --- a/sql/plsql/examples/alter_table.sql +++ b/sql/plsql/examples/alter_table.sql @@ -25,4 +25,16 @@ ALTER TABLE USR_SAT_ADMCC.ACC_R65_OPERACAO MOVE SUBPARTITION SP_INICIAL COMPRESS FOR QUERY HIGH TABLESPACE TBS_SAT_ADMCC_DATA_2005 - UPDATE INDEXES; \ No newline at end of file + UPDATE INDEXES; + +ALTER TABLE fruit ANNOTATIONS (Visibility 'Everyone'); + +ALTER TABLE fruit ANNOTATIONS (drop Visibility); + +ALTER TABLE fruit ANNOTATIONS (add Visibility 'Everyone'); + +ALTER TABLE fruit MODIFY (id ANNOTATIONS (Visibility 'Hidden')); + +ALTER TABLE fruit MODIFY (id ANNOTATIONS (drop Visibility)); + +ALTER TABLE fruit MODIFY (id ANNOTATIONS (add Visibility 'Hidden')); \ No newline at end of file diff --git a/sql/plsql/examples/create_table.sql b/sql/plsql/examples/create_table.sql index 21333e5eb6..af0049b22f 100644 --- a/sql/plsql/examples/create_table.sql +++ b/sql/plsql/examples/create_table.sql @@ -255,4 +255,12 @@ CREATE TABLE "ETUDES"."IMPORT_EXMETI" ( access_method VARCHAR2(16), template_table VARCHAR2(128), timezone VARCHAR2(64)) - SEGMENT CREATION IMMEDIATE NO INMEMORY INITRANS 100; \ No newline at end of file + SEGMENT CREATION IMMEDIATE NO INMEMORY INITRANS 100; + +CREATE TABLE fruit ( + id NUMERIC(9,0) PRIMARY KEY ANNOTATIONS (Visibility 'Everyone')); + +CREATE TABLE fruit ( + id NUMERIC(9,0) PRIMARY KEY, + data varchar2(50)) + ANNOTATIONS (Visibility 'Everyone'); \ No newline at end of file