How to check if MySQL query is valid without executing it?

前端 未结 5 2326
小蘑菇
小蘑菇 2021-02-20 06:24

I\'m making a simple tool that will get a string of MySQL commands and run it (on several DB servers sequentially). I trust the users to be sensible, but mistakes happen, and I\

5条回答
  •  忘掉有多难
    2021-02-20 07:13

    You can temporarily create a stored procedure with your code and unique name. Then you can drop it immediately. Transactions can't rollback SP creation. But be careful, because it just syntax validation, so it doesn't check if an object (in your query) exists or not.

提交回复
热议问题