How can I check the SQL syntax in a .sql file?

后端 未结 7 1232
走了就别回头了
走了就别回头了 2021-02-03 23:20

How can I check the SQL syntax in a .sql file?

7条回答
  •  生来不讨喜
    2021-02-04 00:03

    There are a couple of possiblities. If you are using InnoDB tables that support transactions, you can simply execute a start transaction; at the beginning of your .sql file and a rollback; at the end. MySQL will output any syntax errors.

    If you are testiing UPDATE or DELETE statements, you could add LIMIT 0 to the end to prevent these queries from making any database changes, and still have MySQL check the syntax.

提交回复
热议问题