Currently using 18c but this apparent inconsistency is present in earlier versions (certainly back to 11g).
In this particular case, I am adding multiple out-of-line constraints to an existing table.
All railroad diagrams are found here: https://docs.oracle.com/en/database/oracle/oracle-database/18/sqlrf/ALTER-TABLE.html
This is the railroad diagram for ALTER TABLE
:
Then, this is the railroad diagram for constraint_clauses
:
Finally, this is the railroad diagram for out_of_line_constraint
:
There are no (
and )
or a ,
in the railroad diagram. But the SQL query must have them.
Here is the code that works:
Create table a ( x number );
Alter table a add (
constraint x1 check ( x > 0 ),
constraint x2 check ( x < 10)
);
Where is my mistake in reading and interpreting the railroad diagram? Is there something else I must know?
You don't need parentheses or commas. This works:
alter table a
add constraint x1 check (x > 0)
add constraint x2 check (x < 10);
But it's a documentation bug either way, as the railroad diagram does not indicate that the "constraint_clauses" reference is repeatable.