Skip to content

Commit 924e9cc

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

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed

src/pegjs/oracle.pegjs

+99
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,101 @@ 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+
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+
20272123
literal
20282124
= string
20292125
/ number
@@ -2379,6 +2475,9 @@ KW_ZONEMAP = 'zonemap'i !ident_start { return '
23792475
KW_WITHOUT = 'without'i !ident_start { return 'without'; }
23802476
KW_CONSTRAINTS = 'constraints'i !ident_start { return 'constraints'; }
23812477
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'; }
23822481
23832482
KW_VARYING = 'varying'i !ident_start { return 'varying'; }
23842483
KW_VARCHAR = 'varchar'i !ident_start { return 'varchar'; }

0 commit comments

Comments
 (0)