SQL Query GeneratorDeveloper Tools
Generates CREATE, INSERT, SELECT, UPDATE, and DELETE statements for four databases.
A query pasted on one line hides a missing WHERE, a wrong join, or a quote that breaks the string. Write the statement with the right quoting for your database, then lay it out so every clause can be checked.
A query copied from a log or an ORM usually arrives as one long line. In that form it is hard to see that a LEFT JOIN has the wrong condition, that a GROUP BY is missing a column, or that an UPDATE has no WHERE at all and will change every row.
Quoting is the other common failure. MySQL quotes names with backticks by default. PostgreSQL, SQLite, and standard SQL use double quotes, and SQL Server uses square brackets. Quoting lets you use a name that clashes with a keyword, such as order. Inside a string value, a single quote has to be doubled, so O'Brien becomes 'O''Brien'. Miss that and the statement breaks or, in application code, opens the door to SQL injection.
Uppercase keywords are a style choice. Databases do not care, but uppercase is the most common convention because keywords stand out from table and column names when someone reviews the query.
When you are writing a statement for one table, start with the SQL Query Generator. Pick the database (MySQL, PostgreSQL, SQLite, or SQL Server), enter the table name, and add columns with a name, a type, and the primary key, not null, and default options. Choose CREATE TABLE, INSERT, SELECT, UPDATE, or DELETE. For INSERT, paste rows as CSV and they become one multi-row statement. Identifiers are quoted the way each database expects, and string values go in single quotes with inner quotes doubled. Column types are translated, so an auto-increment key becomes INT NOT NULL AUTO_INCREMENT in MySQL and INTEGER GENERATED ALWAYS AS IDENTITY in PostgreSQL. An UPDATE or DELETE without a WHERE condition gets a warning comment. The generator covers one table at a time and does not build joins, foreign keys, indexes, or subqueries. It writes text in your browser and does not connect to a database.
To read or share a query, paste it into the SQL Formatter, or upload an .sql file. Choose the dialect, the keyword case, and the indent, then press Format. Main clauses such as SELECT, FROM, WHERE, and ORDER BY start at the left margin. Each selected column and each AND or OR condition gets its own line, and subqueries and CASE expressions are indented one more level. Only whitespace, line breaks, and keyword case change. Table names, column names, and string values keep their case. Dialects include standard SQL, MySQL, MariaDB, PostgreSQL, SQLite, SQL Server, Oracle PL/SQL, and BigQuery. Formatting runs in your browser, so queries with real data stay on your device. The formatter does not check whether the SQL is valid. A misspelled column still formats without complaint.
BEGIN ... END blocks and loops is basic, and a comment in the middle of an expression can move to a new line.No. Only whitespace, line breaks, and the case of keywords change. Identifiers and string values stay exactly as they were.
MySQL uses backticks by default. PostgreSQL, SQLite, and standard SQL use double quotes, and SQL Server uses square brackets.
Double it. O'Brien is written as 'O''Brien'.
It is a style choice, and databases do not care. Uppercase is the most common convention because keywords stand out from names.
Tools used in this guide
Generates CREATE, INSERT, SELECT, UPDATE, and DELETE statements for four databases.
Formats SQL queries for MySQL, PostgreSQL, SQLite, SQL Server, and more.