Incorrect railroad diagram for ALTER TABLE with multiple out-of-line constraints?

Viewed 313

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:

enter image description here

Then, this is the railroad diagram for constraint_clauses:

enter image description here

Finally, this is the railroad diagram for out_of_line_constraint:

enter image description here

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?

2 Answers

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.

Create table doc include parentheses:

For one constraint statement, parentheses is optional, for example:

Alter table a add constraint x1 check ( x > 0 )

I don't see parentheses for constraint in doc, which seems missing as you found.

Here's full oracle syntax document

Related