Truncate table in Oracle getting errors

后端 未结 9 1269
忘了有多久
忘了有多久 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 09:12

    A typical approach to delete many rows with many constraints is as follows:

    • create mytable_new with all the columns but without constrains (or create constraints disabled);
    • copy whatever data you need from mytable to mytable_new.
    • enable constraints on mytable_new to see that everything is ok.
    • alter any constraints that reference mytable to reference mytable_new instead and see that everything is ok.
    • drop table mytable.
    • alter table mytable_new rename to mytable.

    It's far faster than deleting a million records with many slow constraints.

提交回复
热议问题