Pop Stack
Pop Stack

Reputation: 944

Is truncation of parent table restricted even when child table is empty?

I can use delete from table_name which works.
Why not truncate?

Upvotes: 1

Views: 775

Answers (1)

Ollie
Ollie

Reputation: 17548

Try:

TRUNCATE TABLE <tablename>;

after disabling the FK constraint.

Truncating cannot be rolled back as it is DDL rather than DML so be careful. It also resets the highwater mark of the table being truncated.

see here for the Oracle docs explanation. and here for a comparison.

N.B.: You cannot truncate the parent table of an enabled foreign key constraint. You must disable the constraint before truncating the table. An exception is that you can truncate the table if the integrity constraint is self-referential.

From the Oracle documantation.

Hope it helps...

Upvotes: 5

Related Questions