@@ -146,6 +146,7 @@ start
146
146
stmt
147
147
= create_table_stmt
148
148
/ drop_table_stmt
149
+ / alter_table_stmt
149
150
150
151
create_table_stmt
151
152
= operation :KW_CREATE _
@@ -2024,6 +2025,101 @@ drop_table_stmt
2024
2025
};
2025
2026
}
2026
2027
2028
+ alter_table_stmt
2029
+ = opertaion: KW_ALTER _
2030
+ object: KW_TABLE _
2031
+ name: schema_table _
2032
+ memoptimize_read: memoptimize_read_clause? _
2033
+ memoptimize_write: memoptimize_write_clause? _
2034
+ body: alter_table_stmt_body {
2035
+ return {
2036
+ opertaion,
2037
+ table,
2038
+ name,
2039
+ memoptimize_read,
2040
+ memoptimize_write,
2041
+ }
2042
+ }
2043
+
2044
+ alter_table_stmt_body
2045
+ // = alter_table_properties
2046
+ // / column_clauses
2047
+ = x: constraint_clauses { return {... x, target: ' constraint' }; }
2048
+ // / alter_table_partitioning
2049
+ // / alter_external_table
2050
+ // / move_table_clause
2051
+ // / modify_to_partitioned
2052
+ // / modify_opaque_type
2053
+ / x: immutable_table_clauses { return {... x, target: ' immutable_table' }; }
2054
+ / x: blockchain_table_clauses { return {... x, target: ' blockchain_table' }; }
2055
+
2056
+ constraint_clauses
2057
+ = add_constraint_clauses
2058
+ / rename_constraint_clauses
2059
+ / drop_constraint_clause
2060
+ / modify_constraint_clause
2061
+
2062
+ modify_constraint_clause
2063
+ = operation: KW_MODIFY _
2064
+ constraint: (
2065
+ KW_PRIMARY _ KW_KEY { return { primary_key: ' primary key' }; } /
2066
+ KW_CONSTRAINT _ name: identifier_name { return { constraint: name }; } /
2067
+ unique: KW_UNIQUE _ LPAR _ columns: comma_separated_identifiers _ RPAR { return { unique, columns }; }
2068
+ ) _
2069
+ state: constraint_state
2070
+ cascade: KW_CASCADE ? {
2071
+ return {
2072
+ state,
2073
+ cascade,
2074
+ operation,
2075
+ constraint,
2076
+ };
2077
+ }
2078
+
2079
+ drop_constraint_clause
2080
+ = operation: KW_DROP _
2081
+ constraint: (
2082
+ KW_PRIMARY _ KW_KEY { return { primary_key: ' primary key' }; } /
2083
+ KW_CONSTRAINT _ name: identifier_name { return { constraint: name }; } /
2084
+ unique: KW_UNIQUE _ LPAR _ columns: comma_separated_identifiers _ RPAR { return { unique, columns }; }
2085
+ ) _
2086
+ cascade: KW_CASCADE ? _
2087
+ index_action: (a: (KW_KEEP / KW_DROP ) _ KW_INDEX { return a; })? _
2088
+ online: KW_ONLINE ? {
2089
+ return {
2090
+ online,
2091
+ cascade,
2092
+ operation,
2093
+ constraint,
2094
+ index_action,
2095
+ };
2096
+ }
2097
+
2098
+ rename_constraint_clauses
2099
+ = operation: KW_RENAME _ KW_CONSTRAINT _
2100
+ old_name: identifier_name _ KW_TO _
2101
+ new_name: identifier_name {
2102
+ return {
2103
+ old_name,
2104
+ new_name,
2105
+ operation,
2106
+ };
2107
+ }
2108
+
2109
+ add_constraint_clauses
2110
+ = operation: KW_ADD _
2111
+ constraint: (out_of_line_ref_constraint / (_ x: out_of_line_constraint _ { return x; } )+ ) {
2112
+ return { operation, constraint };
2113
+ }
2114
+
2115
+ memoptimize_read_clause
2116
+ = KW_MEMOPTIMIZE _ KW_FOR _ KW_READ { return ' memotimize for read' ; }
2117
+ / KW_NO _ KW_MEMOPTIMIZE _ KW_FOR _ KW_READ { return ' no memoptimize for read' ; }
2118
+
2119
+ memoptimize_write_clause
2120
+ = KW_MEMOPTIMIZE _ KW_FOR _ KW_WRITE { return ' memotimize for write' ; }
2121
+ / KW_NO _ KW_MEMOPTIMIZE _ KW_FOR _ KW_WRITE { return ' no memoptimize for write' ; }
2122
+
2027
2123
literal
2028
2124
= string
2029
2125
/ number
@@ -2379,6 +2475,9 @@ KW_ZONEMAP = 'zonemap'i !ident_start { return '
2379
2475
KW_WITHOUT = 'without'i !ident_start { return 'without'; }
2380
2476
KW_CONSTRAINTS = 'constraints'i !ident_start { return 'constraints'; }
2381
2477
KW_PURGE = 'purge'i !ident_start { return 'purge'; }
2478
+ KW_ALTER = 'alter'i !ident_start { return 'alter'; }
2479
+ KW_RENAME = 'rename'i !ident_start { return 'rename'; }
2480
+ KW_ONLINE = 'online'i !ident_start { return 'online'; }
2382
2481
2383
2482
KW_VARYING = 'varying'i !ident_start { return 'varying'; }
2384
2483
KW_VARCHAR = 'varchar'i !ident_start { return 'varchar'; }
0 commit comments