SQL syntax debug: Difference between revisions

From LemonWiki共筆
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 1: Line 1:
How to debug MySQL query syntax
How to debug MySQL query syntax


Goal:  
== Approach 1: Reduce the complexity of Sql query ==
* Reduce the complexity


Steps:
Steps:
Line 9: Line 8:
* Enable the MySQL server log. Details on [[Testing#Database_server]]
* Enable the MySQL server log. Details on [[Testing#Database_server]]
* Disable unnecessary database operation permission
* Disable unnecessary database operation permission
* Beautify the sql syntax e.g.
 
** Using the text editor [http://www.sublimetext.com/ Sublime], and enable the Menu option: {{ kbd | key = View > Syntax >SQL }}. The syntax will become colorful for easy to read!
== Approach 2: Using MySQL syntax checker ==
** [http://www.dpriver.com/pp/sqlformat.htm Instant SQL Formatter]
* [https://www.mysql.com/products/workbench/ MySQL :: MySQL Workbench]
* More on [https://www.quora.com/Where-can-I-find-a-good-MySQL-syntax-checker Where can I find a good MySQL syntax checker? - Quora]
 
== Approach 3: Beautify the Sql syntax ==
 
* Using the text editor [http://www.sublimetext.com/ Sublime], and enable the Menu option: {{ kbd | key = View > Syntax >SQL }}. The syntax will become colorful for easy to read!
* [http://www.dpriver.com/pp/sqlformat.htm Instant SQL Formatter]
 


MySQL server configuration
MySQL server configuration

Revision as of 19:13, 28 April 2017

How to debug MySQL query syntax

Approach 1: Reduce the complexity of Sql query

Steps:

  • Reduce the complexity of SQL syntax ex: reduce the WHERE condition
  • Examine the sub query part only
  • Enable the MySQL server log. Details on Testing#Database_server
  • Disable unnecessary database operation permission

Approach 2: Using MySQL syntax checker

Approach 3: Beautify the Sql syntax

  • Using the text editor Sublime, and enable the Menu option: View > Syntax >SQL. The syntax will become colorful for easy to read!
  • Instant SQL Formatter


MySQL server configuration

Further reading