具有多个离线约束的ALTER TABLE的铁路图不正确?

问题描述 投票:3回答:2

当前使用18c,但是在早期版本中存在这种明显的不一致之处(肯定回溯到11g)。

在这种情况下,我向现有表添加了多个离线约束。

在此处找到所有铁路图:https://docs.oracle.com/en/database/oracle/oracle-database/18/sqlrf/ALTER-TABLE.html

这是ALTER TABLE的铁路图:

enter image description here

然后,这是constraint_clauses的铁路图:

enter image description here

最后,这是out_of_line_constraint的铁路图:

enter image description here

铁路图中没有(),。但是SQL查询必须包含它们。

这里是有效的代码:

Create table a ( x number );

Alter table a add (
  constraint x1 check ( x > 0 ),
  constraint x2 check ( x < 10)
);

我在阅读和解释铁路图时哪里犯了错误?还有其他我必须知道的吗?

sql oracle alter-table
2个回答
2
投票

您不需要需要括号或逗号。这有效:

alter table a 
  add constraint x1 check (x > 0)
  add constraint x2 check (x < 10);

但是无论哪种方式都是文档错误,因为铁路图并不表明“ constraint_clauses”引用是可重复的。


1
投票

[Create table doc包括括号:

<< [

对于一个约束条件语句,括号是可选的,例如:

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

我在文档中没有看到用于约束的括号,您发现的似乎没有。

这里是full oracle syntax document

© www.soinside.com 2019 - 2024. All rights reserved.