Solved

Truncate table

Posted on 2011-02-21
2
379 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
constraint check 2 56
Oracle encryption 12 59
SQL Workhours Count beetween Workhours 3 39
What are Nested Tables? How will u delete 5 rows from Nested Tables ? 3 21
Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

756 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