-
Notifications
You must be signed in to change notification settings - Fork 3.7k
/
PlSqlParser.g4
6768 lines (5951 loc) · 146 KB
/
PlSqlParser.g4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* Oracle(c) PL/SQL 11g Parser
*
* Copyright (c) 2009-2011 Alexandre Porcelli <alexandre.porcelli@gmail.com>
* Copyright (c) 2015-2019 Ivan Kochurkin (KvanTTT, kvanttt@gmail.com, Positive Technologies).
* Copyright (c) 2017-2018 Mark Adams <madams51703@gmail.com>
*
* Licensed 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.
*/
parser grammar PlSqlParser;
options {
tokenVocab=PlSqlLexer;
superClass=PlSqlParserBase;
}
@parser::postinclude {
#include <PlSqlParserBase.h>
}
sql_script
: ((unit_statement | sql_plus_command) SEMICOLON?)* EOF
;
unit_statement
: transaction_control_statements
| alter_cluster
| alter_database
| alter_function
| alter_package
| alter_procedure
| alter_sequence
| alter_session
| alter_trigger
| alter_type
| alter_table
| alter_tablespace
| alter_index
| alter_library
| alter_materialized_view
| alter_materialized_view_log
| alter_user
| alter_view
| analyze
| associate_statistics
| audit_traditional
| unified_auditing
| create_function_body
| create_procedure_body
| create_package
| create_package_body
| create_index
| create_table
| create_tablespace
| create_cluster
| create_context
| create_view //TODO
| create_directory
| create_materialized_view
| create_materialized_view_log
| create_user
| create_sequence
| create_trigger
| create_type
| create_synonym
| drop_function
| drop_package
| drop_procedure
| drop_sequence
| drop_trigger
| drop_type
| data_manipulation_language_statements
| truncate_table
| drop_table
| drop_view
| drop_index
| rename_object
| comment_on_column
| comment_on_table
| anonymous_block
| grant_statement
| procedure_call
;
// DDL -> SQL Statements for Stored PL/SQL Units
// Function DDLs
drop_function
: DROP FUNCTION function_name ';'
;
alter_function
: ALTER FUNCTION function_name COMPILE DEBUG? compiler_parameters_clause* (REUSE SETTINGS)? ';'
;
create_function_body
: CREATE (OR REPLACE)? FUNCTION function_name ('(' parameter (',' parameter)* ')')?
RETURN type_spec (invoker_rights_clause | parallel_enable_clause | result_cache_clause | DETERMINISTIC)*
((PIPELINED? (IS | AS) (DECLARE? seq_of_declare_specs? body | call_spec)) | (PIPELINED | AGGREGATE) USING implementation_type_name) ';'
;
// Creation Function - Specific Clauses
parallel_enable_clause
: PARALLEL_ENABLE partition_by_clause?
;
partition_by_clause
: '(' PARTITION expression BY (ANY | (HASH | RANGE | LIST) paren_column_list) streaming_clause? ')'
;
result_cache_clause
: RESULT_CACHE relies_on_part?
;
relies_on_part
: RELIES_ON '(' tableview_name (',' tableview_name)* ')'
;
streaming_clause
: (ORDER | CLUSTER) expression BY paren_column_list
;
// Package DDLs
drop_package
: DROP PACKAGE BODY? (schema_object_name '.')? package_name ';'
;
alter_package
: ALTER PACKAGE package_name COMPILE DEBUG? (PACKAGE | BODY | SPECIFICATION)? compiler_parameters_clause* (REUSE SETTINGS)? ';'
;
create_package
: CREATE (OR REPLACE)? PACKAGE (schema_object_name '.')? package_name invoker_rights_clause? (IS | AS) package_obj_spec* END package_name? ';'
;
create_package_body
: CREATE (OR REPLACE)? PACKAGE BODY (schema_object_name '.')? package_name (IS | AS) package_obj_body* (BEGIN seq_of_statements)? END package_name? ';'
;
// Create Package Specific Clauses
package_obj_spec
: pragma_declaration
| exception_declaration
| variable_declaration
| subtype_declaration
| cursor_declaration
| type_declaration
| procedure_spec
| function_spec
;
procedure_spec
: PROCEDURE identifier ('(' parameter ( ',' parameter )* ')')? ';'
;
function_spec
: FUNCTION identifier ('(' parameter ( ',' parameter)* ')')?
RETURN type_spec PIPELINED? DETERMINISTIC? (RESULT_CACHE)? ';'
;
package_obj_body
: exception_declaration
| subtype_declaration
| cursor_declaration
| variable_declaration
| type_declaration
| procedure_body
| function_body
| procedure_spec
| function_spec
;
// Procedure DDLs
drop_procedure
: DROP PROCEDURE procedure_name ';'
;
alter_procedure
: ALTER PROCEDURE procedure_name COMPILE DEBUG? compiler_parameters_clause* (REUSE SETTINGS)? ';'
;
function_body
: FUNCTION identifier ('(' parameter (',' parameter)* ')')?
RETURN type_spec (invoker_rights_clause | parallel_enable_clause | result_cache_clause | DETERMINISTIC)*
((PIPELINED? DETERMINISTIC? (IS | AS) (DECLARE? seq_of_declare_specs? body | call_spec)) | (PIPELINED | AGGREGATE) USING implementation_type_name) ';'
;
procedure_body
: PROCEDURE identifier ('(' parameter (',' parameter)* ')')? (IS | AS)
(DECLARE? seq_of_declare_specs? body | call_spec | EXTERNAL) ';'
;
create_procedure_body
: CREATE (OR REPLACE)? PROCEDURE procedure_name ('(' parameter (',' parameter)* ')')?
invoker_rights_clause? (IS | AS)
(DECLARE? seq_of_declare_specs? body | call_spec | EXTERNAL) ';'
;
// Trigger DDLs
drop_trigger
: DROP TRIGGER trigger_name ';'
;
alter_trigger
: ALTER TRIGGER alter_trigger_name=trigger_name
((ENABLE | DISABLE) | RENAME TO rename_trigger_name=trigger_name | COMPILE DEBUG? compiler_parameters_clause* (REUSE SETTINGS)?) ';'
;
create_trigger
: CREATE ( OR REPLACE )? TRIGGER trigger_name
(simple_dml_trigger | compound_dml_trigger | non_dml_trigger)
trigger_follows_clause? (ENABLE | DISABLE)? trigger_when_clause? trigger_body ';'
;
trigger_follows_clause
: FOLLOWS trigger_name (',' trigger_name)*
;
trigger_when_clause
: WHEN '(' condition ')'
;
// Create Trigger Specific Clauses
simple_dml_trigger
: (BEFORE | AFTER | INSTEAD OF) dml_event_clause referencing_clause? for_each_row?
;
for_each_row
: FOR EACH ROW
;
compound_dml_trigger
: FOR dml_event_clause referencing_clause?
;
non_dml_trigger
: (BEFORE | AFTER) non_dml_event (OR non_dml_event)* ON (DATABASE | (schema_name '.')? SCHEMA)
;
trigger_body
: COMPOUND TRIGGER
| CALL identifier
| trigger_block
;
routine_clause
: routine_name function_argument?
;
compound_trigger_block
: COMPOUND TRIGGER seq_of_declare_specs? timing_point_section+ END trigger_name
;
timing_point_section
: bk=BEFORE STATEMENT IS trigger_block BEFORE STATEMENT ';'
| bk=BEFORE EACH ROW IS trigger_block BEFORE EACH ROW ';'
| ak=AFTER STATEMENT IS trigger_block AFTER STATEMENT ';'
| ak=AFTER EACH ROW IS trigger_block AFTER EACH ROW ';'
;
non_dml_event
: ALTER
| ANALYZE
| ASSOCIATE STATISTICS
| AUDIT
| COMMENT
| CREATE
| DISASSOCIATE STATISTICS
| DROP
| GRANT
| NOAUDIT
| RENAME
| REVOKE
| TRUNCATE
| DDL
| STARTUP
| SHUTDOWN
| DB_ROLE_CHANGE
| LOGON
| LOGOFF
| SERVERERROR
| SUSPEND
| DATABASE
| SCHEMA
| FOLLOWS
;
dml_event_clause
: dml_event_element (OR dml_event_element)* ON dml_event_nested_clause? tableview_name
;
dml_event_element
: (DELETE | INSERT | UPDATE) (OF column_list)?
;
dml_event_nested_clause
: NESTED TABLE tableview_name OF
;
referencing_clause
: REFERENCING referencing_element+
;
referencing_element
: (NEW | OLD | PARENT) column_alias
;
// DDLs
drop_type
: DROP TYPE BODY? type_name (FORCE | VALIDATE)? ';'
;
alter_type
: ALTER TYPE type_name
(compile_type_clause
| replace_type_clause
//TODO | {input.LT(2).getText().equalsIgnoreCase("attribute")}? alter_attribute_definition
| alter_method_spec
| alter_collection_clauses
| modifier_clause
| overriding_subprogram_spec
) dependent_handling_clause? ';'
;
// Alter Type Specific Clauses
compile_type_clause
: COMPILE DEBUG? (SPECIFICATION | BODY)? compiler_parameters_clause* (REUSE SETTINGS)?
;
replace_type_clause
: REPLACE invoker_rights_clause? AS OBJECT '(' object_member_spec (',' object_member_spec)* ')'
;
alter_method_spec
: alter_method_element (',' alter_method_element)*
;
alter_method_element
: (ADD | DROP) (map_order_function_spec | subprogram_spec)
;
alter_attribute_definition
: (ADD | MODIFY | DROP) ATTRIBUTE (attribute_definition | '(' attribute_definition (',' attribute_definition)* ')')
;
attribute_definition
: attribute_name type_spec?
;
alter_collection_clauses
: MODIFY (LIMIT expression | ELEMENT TYPE type_spec)
;
dependent_handling_clause
: INVALIDATE
| CASCADE (CONVERT TO SUBSTITUTABLE | NOT? INCLUDING TABLE DATA)? dependent_exceptions_part?
;
dependent_exceptions_part
: FORCE? EXCEPTIONS INTO tableview_name
;
create_type
: CREATE (OR REPLACE)? TYPE (type_definition | type_body) ';'
;
// Create Type Specific Clauses
type_definition
: type_name (OID CHAR_STRING)? FORCE? object_type_def?
;
object_type_def
: invoker_rights_clause? (object_as_part | object_under_part) sqlj_object_type?
('(' object_member_spec (',' object_member_spec)* ')')? modifier_clause*
;
object_as_part
: (IS | AS) (OBJECT | varray_type_def | nested_table_type_def)
;
object_under_part
: UNDER type_spec
;
nested_table_type_def
: TABLE OF type_spec (NOT NULL_)?
;
sqlj_object_type
: EXTERNAL NAME expression LANGUAGE JAVA USING (SQLDATA | CUSTOMDATUM | ORADATA)
;
type_body
: BODY type_name (IS | AS) (type_body_elements)+ END
;
type_body_elements
: map_order_func_declaration
| subprog_decl_in_type
| overriding_subprogram_spec
;
map_order_func_declaration
: (MAP | ORDER) MEMBER func_decl_in_type
;
subprog_decl_in_type
: (MEMBER | STATIC) (proc_decl_in_type | func_decl_in_type | constructor_declaration)
;
proc_decl_in_type
: PROCEDURE procedure_name '(' type_elements_parameter (',' type_elements_parameter)* ')'
(IS | AS) (call_spec | DECLARE? seq_of_declare_specs? body ';')
;
func_decl_in_type
: FUNCTION function_name ('(' type_elements_parameter (',' type_elements_parameter)* ')')?
RETURN type_spec (IS | AS) (call_spec | DECLARE? seq_of_declare_specs? body ';')
;
constructor_declaration
: FINAL? INSTANTIABLE? CONSTRUCTOR FUNCTION type_spec
('(' (SELF IN OUT type_spec ',') type_elements_parameter (',' type_elements_parameter)* ')')?
RETURN SELF AS RESULT (IS | AS) (call_spec | DECLARE? seq_of_declare_specs? body ';')
;
// Common Type Clauses
modifier_clause
: NOT? (INSTANTIABLE | FINAL | OVERRIDING)
;
object_member_spec
: identifier type_spec sqlj_object_type_attr?
| element_spec
;
sqlj_object_type_attr
: EXTERNAL NAME expression
;
element_spec
: modifier_clause? element_spec_options+ (',' pragma_clause)?
;
element_spec_options
: subprogram_spec
| constructor_spec
| map_order_function_spec
;
subprogram_spec
: (MEMBER | STATIC) (type_procedure_spec | type_function_spec)
;
// TODO: should be refactored such as Procedure body and Function body, maybe Type_Function_Body and overriding_function_body
overriding_subprogram_spec
: OVERRIDING MEMBER overriding_function_spec
;
overriding_function_spec
: FUNCTION function_name ('(' type_elements_parameter (',' type_elements_parameter)* ')')?
RETURN (type_spec | SELF AS RESULT)
(PIPELINED? (IS | AS) (DECLARE? seq_of_declare_specs? body))? ';'?
;
type_procedure_spec
: PROCEDURE procedure_name '(' type_elements_parameter (',' type_elements_parameter)* ')' ((IS | AS) call_spec)?
;
type_function_spec
: FUNCTION function_name ('(' type_elements_parameter (',' type_elements_parameter)* ')')?
RETURN (type_spec | SELF AS RESULT) ((IS | AS) call_spec | EXTERNAL VARIABLE? NAME expression)?
;
constructor_spec
: FINAL? INSTANTIABLE? CONSTRUCTOR FUNCTION
type_spec ('(' (SELF IN OUT type_spec ',') type_elements_parameter (',' type_elements_parameter)* ')')?
RETURN SELF AS RESULT ((IS | AS) call_spec)?
;
map_order_function_spec
: (MAP | ORDER) MEMBER type_function_spec
;
pragma_clause
: PRAGMA RESTRICT_REFERENCES '(' pragma_elements (',' pragma_elements)* ')'
;
pragma_elements
: identifier
| DEFAULT
;
type_elements_parameter
: parameter_name type_spec
;
// Sequence DDLs
drop_sequence
: DROP SEQUENCE sequence_name ';'
;
alter_sequence
: ALTER SEQUENCE sequence_name sequence_spec+ ';'
;
alter_session
: ALTER SESSION (
ADVISE ( COMMIT | ROLLBACK | NOTHING )
| CLOSE DATABASE LINK parameter_name
| enable_or_disable COMMIT IN PROCEDURE
| enable_or_disable GUARD
| (enable_or_disable | FORCE) PARALLEL (DML | DDL | QUERY) (PARALLEL (literal | parameter_name))?
| SET alter_session_set_clause
)
;
alter_session_set_clause
: parameter_name '=' parameter_value
;
create_sequence
: CREATE SEQUENCE sequence_name (sequence_start_clause | sequence_spec)* ';'
;
// Common Sequence
sequence_spec
: INCREMENT BY UNSIGNED_INTEGER
| MAXVALUE UNSIGNED_INTEGER
| NOMAXVALUE
| MINVALUE UNSIGNED_INTEGER
| NOMINVALUE
| CYCLE
| NOCYCLE
| CACHE UNSIGNED_INTEGER
| NOCACHE
| ORDER
| NOORDER
;
sequence_start_clause
: START WITH UNSIGNED_INTEGER
;
create_index
: CREATE (UNIQUE | BITMAP)? INDEX index_name
ON (cluster_index_clause | table_index_clause | bitmap_join_index_clause)
UNUSABLE?
';'
;
cluster_index_clause
: CLUSTER cluster_name index_attributes?
;
cluster_name
: (id_expression '.')? id_expression
;
table_index_clause
: tableview_name table_alias? '(' index_expr (ASC | DESC)? (',' index_expr (ASC | DESC)? )* ')'
index_properties?
;
bitmap_join_index_clause
: tableview_name '(' (tableview_name | table_alias)? column_name (ASC | DESC)? (',' (tableview_name | table_alias)? column_name (ASC | DESC)? )* ')'
FROM tableview_name table_alias (',' tableview_name table_alias)*
where_clause local_partitioned_index? index_attributes?
;
index_expr
: column_name
| expression
;
index_properties
: (global_partitioned_index | local_partitioned_index | index_attributes)+
| INDEXTYPE IS (domain_index_clause | xmlindex_clause)
;
domain_index_clause
: indextype local_domain_index_clause? parallel_clause? (PARAMETERS '(' odci_parameters ')' )?
;
local_domain_index_clause
: LOCAL ('(' PARTITION partition_name (PARAMETERS '(' odci_parameters ')' )? (',' PARTITION partition_name (PARAMETERS '(' odci_parameters ')' )? )* ')' )?
;
xmlindex_clause
: (XDB '.')? XMLINDEX local_xmlindex_clause?
parallel_clause? //TODO xmlindex_parameters_clause?
;
local_xmlindex_clause
: LOCAL ('(' PARTITION partition_name (',' PARTITION partition_name //TODO xmlindex_parameters_clause?
)* ')')?
;
global_partitioned_index
: GLOBAL PARTITION BY (RANGE '(' column_name (',' column_name)* ')' '(' index_partitioning_clause ')'
| HASH '(' column_name (',' column_name)* ')'
(individual_hash_partitions
| hash_partitions_by_quantity
)
)
;
index_partitioning_clause
: PARTITION partition_name? VALUES LESS THAN '(' literal (',' literal)* ')'
segment_attributes_clause?
;
local_partitioned_index
: LOCAL (on_range_partitioned_table
| on_list_partitioned_table
| on_hash_partitioned_table
| on_comp_partitioned_table
)?
;
on_range_partitioned_table
: '(' partitioned_table (',' partitioned_table)* ')'
;
on_list_partitioned_table
: '(' partitioned_table (',' partitioned_table)* ')'
;
partitioned_table
: PARTITION partition_name?
(segment_attributes_clause | key_compression)*
UNUSABLE?
;
on_hash_partitioned_table
: STORE IN '(' tablespace (',' tablespace)* ')'
| '(' on_hash_partitioned_clause (',' on_hash_partitioned_clause)* ')'
;
on_hash_partitioned_clause
: PARTITION partition_name? (TABLESPACE tablespace)?
key_compression? UNUSABLE?
;
on_comp_partitioned_table
: (STORE IN '(' tablespace (',' tablespace)* ')' )?
'(' on_comp_partitioned_clause (',' on_comp_partitioned_clause)* ')'
;
on_comp_partitioned_clause
: PARTITION partition_name?
(segment_attributes_clause | key_compression)*
UNUSABLE index_subpartition_clause?
;
index_subpartition_clause
: STORE IN '(' tablespace (',' tablespace)* ')'
| '(' index_subpartition_subclause (',' index_subpartition_subclause)* ')'
;
index_subpartition_subclause
: SUBPARTITION subpartition_name? (TABLESPACE tablespace)?
key_compression? UNUSABLE?
;
odci_parameters
: CHAR_STRING
;
indextype
: (id_expression '.')? id_expression
;
//https://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_1010.htm#SQLRF00805
alter_index
: ALTER INDEX index_name (alter_index_ops_set1 | alter_index_ops_set2) ';'
;
alter_index_ops_set1
: ( deallocate_unused_clause
| allocate_extent_clause
| shrink_clause
| parallel_clause
| physical_attributes_clause
| logging_clause
)+
;
alter_index_ops_set2
: rebuild_clause
| PARAMETERS '(' odci_parameters ')'
| COMPILE
| enable_or_disable
| UNUSABLE
| visible_or_invisible
| RENAME TO new_index_name
| COALESCE
| monitoring_nomonitoring USAGE
| UPDATE BLOCK REFERENCES
| alter_index_partitioning
;
visible_or_invisible
: VISIBLE
| INVISIBLE
;
monitoring_nomonitoring
: MONITORING
| NOMONITORING
;
rebuild_clause
: REBUILD ( PARTITION partition_name
| SUBPARTITION subpartition_name
| REVERSE
| NOREVERSE
)?
( parallel_clause
| TABLESPACE tablespace
| PARAMETERS '(' odci_parameters ')'
//TODO | xmlindex_parameters_clause
| ONLINE
| physical_attributes_clause
| key_compression
| logging_clause
)*
;
alter_index_partitioning
: modify_index_default_attrs
| add_hash_index_partition
| modify_index_partition
| rename_index_partition
| drop_index_partition
| split_index_partition
| coalesce_index_partition
| modify_index_subpartition
;
modify_index_default_attrs
: MODIFY DEFAULT ATTRIBUTES (FOR PARTITION partition_name)?
( physical_attributes_clause
| TABLESPACE (tablespace | DEFAULT)
| logging_clause
)
;
add_hash_index_partition
: ADD PARTITION partition_name? (TABLESPACE tablespace)?
key_compression? parallel_clause?
;
coalesce_index_partition
: COALESCE PARTITION parallel_clause?
;
modify_index_partition
: MODIFY PARTITION partition_name
( modify_index_partitions_ops+
| PARAMETERS '(' odci_parameters ')'
| COALESCE
| UPDATE BLOCK REFERENCES
| UNUSABLE
)
;
modify_index_partitions_ops
: deallocate_unused_clause
| allocate_extent_clause
| physical_attributes_clause
| logging_clause
| key_compression
;
rename_index_partition
: RENAME (PARTITION partition_name | SUBPARTITION subpartition_name)
TO new_partition_name
;
drop_index_partition
: DROP PARTITION partition_name
;
split_index_partition
: SPLIT PARTITION partition_name_old AT '(' literal (',' literal)* ')'
(INTO '(' index_partition_description ',' index_partition_description ')' ) ? parallel_clause?
;
index_partition_description
: PARTITION (partition_name ( (segment_attributes_clause | key_compression)+
| PARAMETERS '(' odci_parameters ')'
)
UNUSABLE?
)?
;
modify_index_subpartition
: MODIFY SUBPARTITION subpartition_name (UNUSABLE
| allocate_extent_clause
| deallocate_unused_clause
)
;
partition_name_old
: partition_name
;
new_partition_name
: partition_name
;
new_index_name
: index_name
;
create_user
: CREATE USER
user_object_name
( identified_by
| identified_other_clause
| user_tablespace_clause
| quota_clause
| profile_clause
| password_expire_clause
| user_lock_clause
| user_editions_clause
| container_clause
)+ ';'
;
// The standard clauses only permit one user per statement.
// The proxy clause allows multiple users for a proxy designation.
alter_user
: ALTER USER
user_object_name
( alter_identified_by
| identified_other_clause
| user_tablespace_clause
| quota_clause
| profile_clause
| user_default_role_clause
| password_expire_clause
| user_lock_clause
| alter_user_editions_clause
| container_clause
| container_data_clause
)+
';'
| user_object_name (',' user_object_name)* proxy_clause ';'
;
alter_identified_by
: identified_by (REPLACE id_expression)?
;
identified_by
: IDENTIFIED BY id_expression
;
identified_other_clause
: IDENTIFIED (EXTERNALLY | GLOBALLY) (AS quoted_string)?
;
user_tablespace_clause
: (DEFAULT | TEMPORARY) TABLESPACE id_expression
;
quota_clause
: QUOTA (size_clause | UNLIMITED) ON id_expression
;
profile_clause
: PROFILE id_expression
;
role_clause
: role_name (',' role_name)*
| ALL (EXCEPT role_name (',' role_name)*)*
;
user_default_role_clause
: DEFAULT ROLE (NONE | role_clause)
;
password_expire_clause
: PASSWORD EXPIRE
;
user_lock_clause
: ACCOUNT (LOCK | UNLOCK)
;
user_editions_clause
: ENABLE EDITIONS
;
alter_user_editions_clause
: user_editions_clause (FOR regular_id (',' regular_id)*)? FORCE?
;
proxy_clause
: REVOKE CONNECT THROUGH (ENTERPRISE USERS | user_object_name)
| GRANT CONNECT THROUGH
( ENTERPRISE USERS
| user_object_name
(WITH (NO ROLES | ROLE role_clause))?
(AUTHENTICATION REQUIRED)?
(AUTHENTICATED USING (PASSWORD | CERTIFICATE | DISTINGUISHED NAME))?
)
;
container_names
: LEFT_PAREN id_expression (',' id_expression)* RIGHT_PAREN
;
set_container_data
: SET CONTAINER_DATA EQUALS_OP (ALL | DEFAULT | container_names)
;
add_rem_container_data
: (ADD | REMOVE) CONTAINER_DATA EQUALS_OP container_names
;
container_data_clause
: set_container_data
| add_rem_container_data (FOR container_tableview_name)?
;
// https://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_4005.htm#SQLRF01105
analyze
: ( ANALYZE (TABLE tableview_name | INDEX index_name) partition_extention_clause?
| ANALYZE CLUSTER cluster_name
)
( validation_clauses
| LIST CHAINED ROWS into_clause1?
| DELETE SYSTEM? STATISTICS
)
';'
;
partition_extention_clause
: PARTITION ( '(' partition_name ')'
| FOR '(' partition_key_value (',' partition_key_value)* ')'
)
| SUBPARTITION ( '(' subpartition_name ')'
| FOR '(' subpartition_key_value (',' subpartition_key_value)* ')'
)
;
validation_clauses
: VALIDATE REF UPDATE (SET DANGLING TO NULL_)?
| VALIDATE STRUCTURE
( CASCADE FAST
| CASCADE online_or_offline? into_clause?
| CASCADE
)?
online_or_offline? into_clause?
;
online_or_offline
: OFFLINE
| ONLINE
;
into_clause1
: INTO tableview_name?