Solved

Truncate table

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ORA-00972: identifier is too long from Unix but not from Windows in SQLPLUS 17 97
clob to char in oracle 3 61
Oracle collections 15 26
ORA-02288: invalid OPEN mode 2 56
Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.

792 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