Oracle 更改表删除约束删除索引在语法上是否有效?

Tom*_*ský 5 oracle syntax alter-table oracle11g

我有 Oracle 11.2.0.2.0 和一个由以下脚本创建的具有唯一约束的表:

    create table foo (id varchar(26) not null, name varchar(50) not null);
    alter table foo add constraint pk_foo primary key (id);
    /**/
    alter table foo add constraint un_foo unique (name); 
Run Code Online (Sandbox Code Playgroud)

我需要删除唯一约束,这很容易:

    alter table foo drop constraint un_foo;
Run Code Online (Sandbox Code Playgroud)

麻烦的是:当数据库在 SQL Developer 中备份然后恢复时,un_foo唯一索引是通过放置在行的显式命令创建的/**/

    CREATE UNIQUE INDEX un_foo ON foo (name);
Run Code Online (Sandbox Code Playgroud)

上面的alter 命令不会删除这种显式创建的索引。我意识到以下命令有效:

    alter table foo drop constraint un_foo drop index;
Run Code Online (Sandbox Code Playgroud)

对于主键,类似的命令alter table foo drop primary key drop index文档Oracle 开发人员社区讨论中。此外,AskTom 的这个答案也使用了这种语法(对于keep index)。但是,我在铁路alter table命令图中看不到这种语法的任何推理。

问题:语法alter table foo drop constraint un_foo drop index合法吗?如果是这样,基于铁路图中的哪些文件或流程?如果没有,为什么命令不会失败?

谢谢!

Tom*_*ský 4

根据@ Chris Saxon对我发布到 AskTom 的等效问题的回答,该语法被确认为有效,但不存在于文档中。到底是文档错误还是意外副作用的决定仍然悬而未决。

我个人决定依赖该语法,因为除其他外,My Oracle Support 中也建议使用该语法。

如果需要绝对安全(阅读:符合文档),唯一的可能性是使用 statements alter table foo drop unique (name) drop index;

我在博客文章(捷克语)中总结了有关此问题的(不是那么实质性的)情况。