How to Validate SQL Queries Online: Step-by-Step Tutorial
Table of Contents
Step 1: Open the SQL Validator
Go to the SQL Validator page. You will see a code editor area, a dialect selector, and mode tabs for Validate, Format, and Explain. The validator is selected by default.
Step 2: Select Your Dialect
Use the dialect dropdown to select your target database: Generic SQL, PostgreSQL, MySQL, T-SQL (SQL Server), or SQLite. This is important because each dialect has different syntax rules. A query that is valid in PostgreSQL may be invalid in MySQL.
If you are unsure, start with Generic SQL. You can switch dialects and re-validate to see dialect-specific issues.
Step 3: Paste Your SQL
Paste your SQL query into the editor. The editor supports tab indentation and Ctrl+Enter to run the validator. You can also click the "Load Sample" button to try a sample query.
Example Query to Validate
SELECT c.name, COUNT(o.id
FROM customers c
JOIN orders o ON c.id = o.customer_id
WHERE o.status = 'paid'
GROUP BY c.name
This query has a deliberate error โ an unclosed parenthesis after COUNT(o.id.
Step 4: Click "Validate SQL"
Click the blue "Validate SQL" button or press Ctrl+Enter. The results panel appears below the editor with a summary badge and a detailed list of errors and warnings.
Step 5: Review the Results
The validator shows:
- Error badge โ Red for errors, yellow for warnings only, green for valid
- Error list โ Each error with a description and line number when available
- Statistics โ Statement count, query type, whether DDL is present, and the active dialect
Fix the reported errors in your SQL and validate again until the result shows green.
Step 6: Try Dialect-Specific Validation
Change the dialect to see different results. For example, this query is valid in PostgreSQL but invalid in MySQL:
SELECT name::text FROM users WHERE name ILIKE '%john%'
With PostgreSQL selected, it passes. Switch to MySQL and you get two errors: :: is not supported and ILIKE is not available.
Step 7: Check for Dangerous Queries
The validator warns about dangerous operations. Try pasting:
DELETE FROM orders
The validator flags this with a warning: "DELETE without WHERE clause โ this will delete ALL rows." This is syntactically valid SQL, but almost certainly not what you intended.
Step 8: Share Your Validation
Click the Share button to generate a URL that anyone can open to see the same SQL and validation results. The SQL is encoded in the URL โ no server storage is involved.
Ready to validate your own SQL?
Open SQL ValidatorNext Steps
After validating your SQL, use the SQL Formatter to clean up the formatting, and the SQL Query Explainer to get a plain English breakdown of what the query does.
Related Tools & Guides
Further reading: MySQL โ SQL Statement Syntax ยท SQLite โ SQL Language Reference
