Solved

Deleting rows

Posted on 2011-02-22
4
339 Views
Last Modified: 2012-05-11
If I disable the FK constraints and then delete rows from the parent table, will I be able to enable the FK constraints again or will the referential integrity be disrupted and I will not be able to enable the FK constraints?
0
Comment
Question by:msimons4
  • 2
4 Comments
 
LVL 73

Accepted Solution

by:
sdstuber earned 167 total points
Comment Utility
the FK's cannot be enabled if the referenced parent records are deleted
0
 
LVL 76

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 333 total points
Comment Utility
You've asked a lot of questions recently on this topic.

What are you really after?  If you can provide us with the 'big picture' maybe we can save you asking a lot of similar questions.

On topic:  Do not disable constraints on a live database.
0
 

Author Comment

by:msimons4
Comment Utility
Trying to get producting 300G down to a reasonable size for the developers laptops. A lot of tables need to have rows deleted based on date and other tables need to be truncated? The FK don't have on delete cascade.
0
 
LVL 76

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 333 total points
Comment Utility
Instead of deleting down, why not create an 'empty' database and a 'test baseline' by selecting/inserting known rows.

Use exp with no rows to create the empty database.

If the constraints are set up properly you might be able to get by with an exp/imp with a QUERY clause and do it all at once.  Once you have this baseline export complete, just keep reusing it.

Short of that:  Just delete the children first, then the parents.

For what it's worth, I have a baseline export DMP file that I use to reload ALL my test/dev databases.  It makes life very easy when I need to refresh/reset a dev/test instance.

It's 100% known data.
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

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

743 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

8 Experts available now in Live!

Get 1:1 Help Now