Solved

Truncate table

Posted on 2011-02-21
2
380 Views
Last Modified: 2012-05-11
When you truncate a table does it automatically delete the child records or are the child's table FK consstraints disabled?
0
Comment
Question by:msimons4
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 34947781
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.
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 34947803
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');
commit;

truncate table tab1;
delete from tab1;
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
Via a live example, show how to take different types of Oracle backups using RMAN.

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question