Solved

Truncate table

Posted on 2011-02-21
2
375 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
  • 2
2 Comments
 
LVL 76

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 76

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
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…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to recover a database from a user managed backup

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now