1

I along with my father have decided to add foreign keys to our MySQL database, we have them disabled. We would like to try to enable them and delete few rows from one of our tables, but we would like to know what it would do, or if not possible, what has it done so that we can say if it expected result, or we need to tweak them.

Is there a way to visualise what will DELETE do?

Or,

Is there a way to tell what rows are missing once the query ran?

PS: We will do a backup beforehand if anything goes terribly wrong.

Akxe
  • 9,694
  • 3
  • 36
  • 71
  • I mean sort of... The **answer to this question is then no**. Sad... – Akxe May 11 '20 at 23:29
  • Well, one of the most powerful tools in software development is automated regression testing. So you are better off if you set yourself up for this to be simply part of your testing & test development anyway. DDL is just as much code that should be tested as triggers & DML. PS You can write a recursive SQL query similar in intent to the answer's code querying the FK table. [How to create a MySQL hierarchical recursive query](https://stackoverflow.com/q/20215744/3404097) – philipxy May 12 '20 at 00:26
  • I expect many duplicates of this question, besides other resources on the web. That was my first SO hit from my first effortless google--'mysql report what delete will cascade' (& 2nd overall after a [dba.se] hit). Before considering posting please read your textbook and/or manual & google any error message or many clear, concise & precise phrasings of your question/problem/goal, with & without your particular strings/names & site:stackoverflow.com & tags; read many answers. If you post a question, use one phrasing as title. Reflect your research. See [ask] & the voting arrow mouseover texts. – philipxy May 12 '20 at 00:28

0 Answers0