Truncate table

When you truncate a table does it automatically delete the child records or are the child's table FK consstraints disabled?
Who is Participating?
slightwv (䄆 Netminder)Connect With a Mentor Commented:
Give me a chance to answer in the other question.

Truncate will not work if child rows exist.

When in doubt, create two cables and try it.
slightwv (䄆 Netminder) Commented:
Here's a quick a simple test to show all this in action.

drop table tab1 purge;
create table tab1(col1 char(1) primary key);

drop table tab2 purge;
create table tab2(col1 char(1), constraint tab2_fk foreign key(col1)
references tab1(col1) on delete cascade);

insert into tab1 values('a');
insert into tab2 values('a');

truncate table tab1;
delete from tab1;
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.