Skip to content

Commit 7b35b43

Browse files
committed
add alter table properties
1 parent 3ff2eec commit 7b35b43

File tree

1 file changed

+170
-3
lines changed

1 file changed

+170
-3
lines changed

src/pegjs/oracle.pegjs

Lines changed: 170 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ relational_table
211211
= relational_properties:(LPAR _ c:relational_properties _ RPAR { return c; })?
212212
blockchain_clauses:blockchain_table_clauses?_
213213
immutable_clauses:immutable_table_clauses? _
214-
collation:(d:KW_DEFAULT _ KW_COLLATION _ name:identifier_name { return { name, default: d }; })? _
214+
collation:default_collation_clause? _
215215
on_commit_definition:(KW_ON _ KW_COMMIT _ operation:(KW_DROP / KW_PRESERVE) _ KW_DEFINITION { return { operation }; })? _
216216
on_commit_rows:(KW_ON _ KW_COMMIT _ operation:(KW_DROP / KW_PRESERVE) _ KW_ROWS { return { operation }; })? _
217217
physical_properties:physical_properties? _
@@ -2059,9 +2059,9 @@ alter_table_stmt_setting
20592059
}
20602060
20612061
alter_table_stmt_body
2062-
// = alter_table_properties
2062+
= alter_table_properties
20632063
// / column_clauses
2064-
= x:constraint_clauses { return {...x, target: 'constraint' }; }
2064+
/ x:constraint_clauses { return {...x, target: 'constraint' }; }
20652065
// / alter_table_partitioning
20662066
// / alter_external_table
20672067
// / move_table_clause
@@ -2070,6 +2070,151 @@ alter_table_stmt_body
20702070
/ x:immutable_table_clauses { return {...x, target: 'immutable_table' }; }
20712071
/ x:blockchain_table_clauses { return {...x, target: 'blockchain_table' }; }
20722072

2073+
alter_table_properties
2074+
= KW_READ _ KW_ONLY { return { read_only: 'read only' }; }
2075+
/ KW_READ _ KW_ONLY { return { read_write: 'read write' }; }
2076+
/ KW_REKEY _ rekey:encryption_spec { return { rekey }; }
2077+
/ default_collation_clause
2078+
/ KW_NO? _ KW_ROW _ KW_ARCHIVAL { return { row_archival: `${no ? 'no ' : ''} row archival` }; }
2079+
/ action:KW_DROP _ target:KW_CLUSTERING { return { action, target }; }
2080+
/ action:KW_MODIFY _ target:KW_CLUSTERING _ when:clustering_when? _ zonemap:zonemap_clause?
2081+
{ return { action, target, when, zonemap }; }
2082+
/ action:KW_ADD _ attribute:attribute_clusering_clause { return { action, attribute }; }
2083+
/ shrink_clause
2084+
/ body:(
2085+
alter_table_properties_options /
2086+
action:KW_RENAME _ KW_TO _ new_name:identifier_name { return { action, new_name }; }
2087+
) _
2088+
iot:alter_iot_clauses? _
2089+
xmlschema:alter_XMLSchema_clause? {
2090+
return { ...body, iot, xmlschema };
2091+
}
2092+
2093+
alter_table_properties_options
2094+
= physical_attributes_clause
2095+
/ logging_clause
2096+
/ table_compression
2097+
/ inmemory_table_clause
2098+
/ ilm_clause
2099+
/ supplemental_table_logging
2100+
/ allocate_extent_clause
2101+
/ deallocate_unused_clause
2102+
/ cache:(KW_CACHE / KW_NOCACHE) { return { cache }; }
2103+
/ result_cache_clause
2104+
/ upgrade_table_clause
2105+
/ records_per_block_clause
2106+
/ parallel_clause
2107+
/ row_movement_clause
2108+
/ logical_replication_clause
2109+
/ flashback_archive_clause
2110+
2111+
records_per_block_clause
2112+
= records_per_block:(KW_MINIMIZE / KW_NOMINIMIZE) _ KW_RECORDS_PER_BLOCK {
2113+
return { records_per_block };
2114+
}
2115+
2116+
upgrade_table_clause
2117+
= action:KW_UPGRADE _
2118+
including_data:(not:KW_NOT? _ KW_INCLUDING _ KW_DATA { return `${not? 'not ' : ''} including data`; }) _
2119+
column_properties:column_properties {
2120+
return { action, including_data, column_properties };
2121+
}
2122+
2123+
supplemental_table_logging
2124+
= action:KW_ADD _ log:supplemental_logging_props { return { action, log }; }
2125+
/ action:KW_DROP _ log:(supplemental_id_key_clause / KW_GROUP _ group:identifier_name { return { group }; }) {
2126+
return { action, log };
2127+
}
2128+
2129+
alter_XMLSchema_clause
2130+
= permission:KW_ALLOW _ schema:(KW_ANYSCHEMA / KW_NONSCHEMA) { return { permission, schema }; }
2131+
/ permission:KW_DISALLOW _ schema:KW_NONSCHEMA { return { permission, schema }; }
2132+
2133+
alter_iot_clauses
2134+
= coalesce:KW_COALESCE { return { coalesce }; }
2135+
/ alter_overflow_clause
2136+
/ alter_mapping_table_clauses
2137+
/ index_org_table_clause
2138+
2139+
alter_mapping_table_clauses
2140+
= mapping:KW_MAPPING _
2141+
table:KW_TABLE _
2142+
allocate:(allocate_extent_clause / deallocate_unused_clause) {
2143+
return { table, mapping, allocate };
2144+
}
2145+
2146+
alter_overflow_clause
2147+
= add_overflow_clause
2148+
/ overflow:KW_OVERFLOW _
2149+
target:(
2150+
_
2151+
x:(
2152+
segment_attributes_clause /
2153+
shrink_clause /
2154+
deallocate_unused_clause /
2155+
allocate_extent_clause
2156+
) { return x; }
2157+
)+ {
2158+
return { overflow, target };
2159+
}
2160+
2161+
allocate_extent_clause
2162+
= KW_ALLOCATE _ KW_EXTENT _
2163+
allocate_extent:(
2164+
LPAR _
2165+
xs:(
2166+
_
2167+
x:(
2168+
KW_SIZE _ size:size_clause { return { size }; } /
2169+
KW_INSTANCE _ instance:integer { return { instance }; } /
2170+
KW_DATAFILE _ datafile:single_quoted_str { return { datafile }; }
2171+
) _ { return x; }
2172+
)+
2173+
_ RPAR { return xs; }
2174+
)? {
2175+
return { allocate_extent };
2176+
}
2177+
2178+
deallocate_unused_clause
2179+
= deallocate:KW_DEALLOCATE _ unused:KW_UNUSED _ keep:(KW_KEEP _ x:size_clause { return x; })? {
2180+
return { deallocate, unused, keep };
2181+
}
2182+
2183+
add_overflow_clause
2184+
= action:KW_ADD _
2185+
overflow:KW_OVERFLOW _
2186+
segment_attributes:segment_attributes_clause? _
2187+
partition:add_overflow_clause_partitions? {
2188+
return {
2189+
action,
2190+
overflow,
2191+
partition,
2192+
segment_attributes,
2193+
};
2194+
}
2195+
2196+
add_overflow_clause_partitions
2197+
= LPAR _
2198+
x:add_overflow_clause_partition
2199+
xs:(_ COMMA _ a:add_overflow_clause_partition { return a; })* _
2200+
RPAR {
2201+
return [x, ...xs];
2202+
}
2203+
2204+
add_overflow_clause_partition
2205+
= partition:KW_PARTITION _ segment_attributes:segment_attributes_clause? {
2206+
return { partition, segment_attributes};
2207+
}
2208+
2209+
shrink_clause
2210+
= KW_SHRINK _ KW_SPACE _ compact:KW_COMPACT _ cascade:KW_CASCADE {
2211+
return {
2212+
cascade,
2213+
compact,
2214+
shrink_space: 'shrink space',
2215+
};
2216+
}
2217+
20732218
constraint_clauses
20742219
= add_constraint_clauses
20752220
/ rename_constraint_clauses
@@ -2137,6 +2282,9 @@ memoptimize_write_clause
21372282
= KW_MEMOPTIMIZE _ KW_FOR _ KW_WRITE { return 'memotimize for write'; }
21382283
/ KW_NO _ KW_MEMOPTIMIZE _ KW_FOR _ KW_WRITE { return 'no memoptimize for write'; }
21392284

2285+
default_collation_clause
2286+
= d:KW_DEFAULT _ KW_COLLATION _ name:identifier_name { return { name, default: d }; }
2287+
21402288
literal
21412289
= string
21422290
/ number
@@ -2499,6 +2647,25 @@ KW_LOCK = 'lock'i !ident_start { return '
24992647
KW_TRIGGERS = 'triggers'i !ident_start { return 'triggers'; }
25002648
KW_CONTAINER_MAP = 'container_map'i !ident_start { return 'container_map'; }
25012649
KW_CONTAINERS_DEFAULT = 'containers_default'i !ident_start { return 'containers_default'; }
2650+
KW_REKEY = 'rekey'i !ident_start { return 'rekey'; }
2651+
KW_SHRINK = 'shrink'i !ident_start { return 'shrink'; }
2652+
KW_SPACE = 'space'i !ident_start { return 'space'; }
2653+
KW_COMPACT = 'compact'i !ident_start { return 'compact'; }
2654+
KW_COALESCE = 'coalesce'i !ident_start { return 'coalesce'; }
2655+
KW_DEALLOCATE = 'deallocate'i !ident_start { return 'deallocate'; }
2656+
KW_UNUSED = 'unused'i !ident_start { return 'unused'; }
2657+
KW_ALLOCATE = 'allocate'i !ident_start { return 'allocate'; }
2658+
KW_EXTENT = 'extent'i !ident_start { return 'extent'; }
2659+
KW_INSTANCE = 'instance'i !ident_start { return 'instance'; }
2660+
KW_DATAFILE = 'datafile'i !ident_start { return 'datafile'; }
2661+
KW_SIZE = 'size'i !ident_start { return 'size'; }
2662+
KW_ANYSCHEMA = 'anyschema'i !ident_start { return 'anyschema'; }
2663+
KW_NONSCHEMA = 'nonschema'i !ident_start { return 'nonschema'; }
2664+
KW_DISALLOW = 'disallow'i !ident_start { return 'disallow'; }
2665+
KW_UPGRADE = 'upgrade'i !ident_start { return 'upgrade'; }
2666+
KW_MINIMIZE = 'minimize'i !ident_start { return 'minimize'; }
2667+
KW_NOMINIMIZE = 'nominimize'i !ident_start { return 'nominimize'; }
2668+
KW_RECORDS_PER_BLOCK = 'records_per_block'i !ident_start { return 'records_per_block'; }
25022669
25032670
KW_VARYING = 'varying'i !ident_start { return 'varying'; }
25042671
KW_VARCHAR = 'varchar'i !ident_start { return 'varchar'; }

0 commit comments

Comments
 (0)