Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7020035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:15:55+00:00 2026-05-27T23:15:55+00:00

Every so often I have to remove a user from our database. Users are

  • 0

Every so often I have to remove a user from our database. Users are stored in a table called TPM_USER. The problem is, there’s a bunch of tables that have a foreign key constraint on TPM_USER.USERID. To make matters worse, these constraints are using ON CASCADE DELETE. The other day, I deleted a user that I thought was not in use by anything (it was a duplicate user mistakenly created a few hours before), but it wiped out a bunch of important data without any warning.

Personally, I hate cascading deletes. I think they’re dangerous and should only be used if the two entities are indeed mutually dependent. I’d love to remove them all, but this schema is rather complicated and it would probably be too big of a change to bite off at this time.

My question: Before running a DELETE statement on TPM_USER, can I have Oracle tell me exactly what will be deleted as a result? Or, can I temporarily disable any cascading and get an error if any foreign keys are violated instead?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:15:55+00:00Added an answer on May 27, 2026 at 11:15 pm

    In answer to your question I don’t know of any easy way to show what would be deleted in a cascade delete statement. You could script it but it would be quite complex since you will have to walk the dependency tree dynamically only showing records pertinent to your delete criteria.

    Anyway, you can disable the constraint by using:

    alter table TABLE_NAME disable constraint FK_CONSTRAINT_NAME;
    

    ( use ‘enable’ to re-enable it ).

    Obviously you should be aware if you do this and another user deletes from the same table then Oracle won’t be enforcing that constraint and bad things could happen.

    You can get a list of all table/constraint names referencing TPM_USER.USERID with:

    select table_name, constraint_name from user_constraints 
      where r_constraint_name in (
        select constraint_name 
        from user_constraints
        where constraint_type = 'P'
        and table_name = 'TPM_USER' ); 
    

    ( use all_constraints if you have cross-schema dependencies )

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Windows executable (whoami) which is crashing every so often. It's called
I have a BroadcastReceiver which is called every so often, and I have noticed
So we have a database. Every so often we'll add a new data set
Every so often I find that I have accidentally broken data binding in my
Does anyone have any problems with VS2008 on Vista? For me every so often
I have an external stylesheet that has specific IE-hacks. Every so often my site
This is a problem I come across every so often; I always end up
I have a launchd daemon that every so often uploads some data via a
Every so often when I'm debugging, I get this message in nice brown text
I'm working on a webapp, and every so often we run into situations where

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.