Skip to content

Commit b5f3ed4

Browse files
committed
add alter table constaint clause
1 parent 914bb8a commit b5f3ed4

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

src/pegjs/oracle.pegjs

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ start
146146
stmt
147147
= create_table_stmt
148148
/ drop_table_stmt
149+
/ alter_table_stmt
149150

150151
create_table_stmt
151152
= operation:KW_CREATE _
@@ -2024,6 +2025,107 @@ drop_table_stmt
20242025
};
20252026
}
20262027

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+
settings:alter_table_stmt_settings? {
2036+
return {
2037+
name,
2038+
table,
2039+
settings,
2040+
opertaion,
2041+
memoptimize_read,
2042+
memoptimize_write,
2043+
}
2044+
}
2045+
2046+
// TODO:
2047+
alter_table_stmt_settings
2048+
= ""
2049+
2050+
alter_table_stmt_body
2051+
// = alter_table_properties
2052+
// / column_clauses
2053+
= x:constraint_clauses { return {...x, target: 'constraint' }; }
2054+
// / alter_table_partitioning
2055+
// / alter_external_table
2056+
// / move_table_clause
2057+
// / modify_to_partitioned
2058+
// / modify_opaque_type
2059+
/ x:immutable_table_clauses { return {...x, target: 'immutable_table' }; }
2060+
/ x:blockchain_table_clauses { return {...x, target: 'blockchain_table' }; }
2061+
2062+
constraint_clauses
2063+
= add_constraint_clauses
2064+
/ rename_constraint_clauses
2065+
/ drop_constraint_clause
2066+
/ modify_constraint_clause
2067+
2068+
modify_constraint_clause
2069+
= operation:KW_MODIFY _
2070+
constraint:(
2071+
KW_PRIMARY _ KW_KEY { return { primary_key: 'primary key' }; } /
2072+
KW_CONSTRAINT _ name:identifier_name { return { constraint: name }; } /
2073+
unique:KW_UNIQUE _ LPAR _ columns:comma_separated_identifiers _ RPAR { return { unique, columns }; }
2074+
) _
2075+
state:constraint_state
2076+
cascade:KW_CASCADE? {
2077+
return {
2078+
state,
2079+
cascade,
2080+
operation,
2081+
constraint,
2082+
};
2083+
}
2084+
2085+
drop_constraint_clause
2086+
= operation:KW_DROP _
2087+
constraint:(
2088+
KW_PRIMARY _ KW_KEY { return { primary_key: 'primary key' }; } /
2089+
KW_CONSTRAINT _ name:identifier_name { return { constraint: name }; } /
2090+
unique:KW_UNIQUE _ LPAR _ columns:comma_separated_identifiers _ RPAR { return { unique, columns }; }
2091+
) _
2092+
cascade:KW_CASCADE? _
2093+
index_action:(a:(KW_KEEP / KW_DROP) _ KW_INDEX { return a; })? _
2094+
online:KW_ONLINE? {
2095+
return {
2096+
online,
2097+
cascade,
2098+
operation,
2099+
constraint,
2100+
index_action,
2101+
};
2102+
}
2103+
2104+
rename_constraint_clauses
2105+
= operation:KW_RENAME _ KW_CONSTRAINT _
2106+
old_name:identifier_name _ KW_TO _
2107+
new_name:identifier_name {
2108+
return {
2109+
old_name,
2110+
new_name,
2111+
operation,
2112+
};
2113+
}
2114+
2115+
add_constraint_clauses
2116+
= operation:KW_ADD _
2117+
constraint:(out_of_line_ref_constraint / (_ x:out_of_line_constraint _ { return x; } )+) {
2118+
return { operation, constraint };
2119+
}
2120+
2121+
memoptimize_read_clause
2122+
= KW_MEMOPTIMIZE _ KW_FOR _ KW_READ { return 'memotimize for read'; }
2123+
/ KW_NO _ KW_MEMOPTIMIZE _ KW_FOR _ KW_READ { return 'no memoptimize for read'; }
2124+
2125+
memoptimize_write_clause
2126+
= KW_MEMOPTIMIZE _ KW_FOR _ KW_WRITE { return 'memotimize for write'; }
2127+
/ KW_NO _ KW_MEMOPTIMIZE _ KW_FOR _ KW_WRITE { return 'no memoptimize for write'; }
2128+
20272129
literal
20282130
= string
20292131
/ number
@@ -2379,6 +2481,9 @@ KW_ZONEMAP = 'zonemap'i !ident_start { return '
23792481
KW_WITHOUT = 'without'i !ident_start { return 'without'; }
23802482
KW_CONSTRAINTS = 'constraints'i !ident_start { return 'constraints'; }
23812483
KW_PURGE = 'purge'i !ident_start { return 'purge'; }
2484+
KW_ALTER = 'alter'i !ident_start { return 'alter'; }
2485+
KW_RENAME = 'rename'i !ident_start { return 'rename'; }
2486+
KW_ONLINE = 'online'i !ident_start { return 'online'; }
23822487
23832488
KW_VARYING = 'varying'i !ident_start { return 'varying'; }
23842489
KW_VARCHAR = 'varchar'i !ident_start { return 'varchar'; }

0 commit comments

Comments
 (0)