Truncate table in Oracle getting errors

后端 未结 9 1289
忘了有多久
忘了有多久 2021-02-02 08:11

I got the problem is when I run following command in Oracle, I encounter the error.

Truncate table mytable;

Errors:

         


        
9条回答
  •  滥情空心
    2021-02-02 08:51

    Oracle 12c introduced a feature to truncate a table that is a parent of a referential integrity constraint having ON DELETE rule.

    Instead of truncate table tablename; use:

    TRUNCATE TABLE tablename CASCADE;
    

    From Oracle truncate table documentation:

    If you specify CASCADE, then Oracle Database truncates all child tables that reference table with an enabled ON DELETE CASCADE referential constraint. This is a recursive operation that will truncate all child tables, granchild tables, and so on, using the specified options.

提交回复
热议问题