0

How can I be sure that a query was not executed?

For example, I try to execute

update `table` set `a`='b' 

and got the error 2006 server has gone away

  • If you're worried about this, use transactions. – ceejayoz Mar 6 '19 at 23:03
  • SELECT COUNT(DISTINCT a), COUNT(*) FROM table; to determine current DISTINCT number of values in your a column and total row count – Wilson Hauck Mar 10 '19 at 19:19
0

Don't run the SQL statement :-)

If you want the mysql client to stop you running it, there is a --safe-updates aka --i-am-a-dummy option.

If you want the server to rollback, use innodb tables that provide transactional support.

For the error see gone away.

| improve this answer | |
0

How can I be sure that a query was not executed?

It did execute and it broke your database in doing so!

As such, when you next start your database, it will perform an "Instance Recovery" and undo any changes that were not committed at the point the instance died.

Once that is complete then it will be as if the query never ran - the database will have "undone" everything that the query did (to it!).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.