Skip to Main Content

Oracle Database Free

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Documentation claims that ALTER TABLE IF EXISTS is valid syntax, but it isn't (ORA-11557)

Lukas EderNov 14 2023 — edited Nov 14 2023

The documentation of Oracle 23c's ALTER INDEX statement claims that IF EXISTS is a valid clause:

https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-INDEX.html

But it doesn't work:

create table t (i int);
create index i on t (i);
alter index if exists i rename to j;

Leading to:

ORA-11557: IF EXISTS clause cannot be used with the current DDL

This resource here explains why it isn't a valid clause:

https://docs.oracle.com/en/database/oracle/oracle-database/23/errmg/ORA-09870.html#GUID-3FF4C160-2D5E-45B9-AA16-12A048CEF8BA

ORA-11557: IF EXISTS clause cannot be used with the current DDL

Cause: IF EXISTS clause cannot be used with DDL statements that may move data, DDLs that recompile a materialized view, DDLs that alter an index or DDLs that drop a private temporary table. Examples: ALTER TABLE table ADD|DROP PARTITION ... ALTER TABLE table COALESCE PARTITION ... ALTER TABLE table MOVE ... ALTER MATERIALIZED VIEW <mat_view> MERGE PARTITIONS ... ALTER MATERIALIZED VIEW <mat_view> COMPILE ... ALTER INDEX index ... DROP TEMPORARY TABLE ... Please check the documentation for a list of DDL statements that are not supported.

This post has been answered by MartinBach-Oracle on Nov 16 2023
Jump to Answer
Comments
Post Details
Added on Nov 14 2023
4 comments
699 views