0

I have list of tables (Mysql) where some of them have reference.

I want to to generate delete script for all the tables based on time column.

NOTE: we can not user delete Cascade I can not disable the keys as it is production system.

4
  • 1
    Your question is unanswerable given the massive lack of information. Please include table structure and data. Commented Mar 20, 2018 at 9:42
  • U can think any table structure as it do not have to do any thing with data. Commented Mar 20, 2018 at 10:03
  • Foreign key constraints keep you from deleting one or more rows in a table. Apparently you don't want to delete the rows with foreign keys because you don't want to use delete cascade. Also, you don't want to orphan those rows because you don't want to turn off foreign key checks. Just what do you want to do with those rows with foreign keys? That seems more of a business question than a technical question. Commented Mar 20, 2018 at 13:51
  • yes you are right but it should be common issue if we have to delete data in prod .. Commented Mar 21, 2018 at 2:37

1 Answer 1

3

You can temporarily disable check reference

SET foreign_key_checks = 0;
Sign up to request clarification or add additional context in comments.

1 Comment

thanks for response but we can not disable key in prod.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.