Developer Tools
SQL Query Generator
Generate common SQL statements without typing boilerplate. Enter a table name and columns, choose your database, and get correctly quoted CREATE TABLE, SELECT, INSERT, UPDATE or DELETE statements.
Generate SQL
Enter one column per line as "name type", for example "email VARCHAR(255)". The type is only used for CREATE TABLE.
How to Use the SQL Generator
- Enter the table name and choose your database.
- List the columns, one per line, with a data type for CREATE TABLE.
- Choose the statement type and the key column used in WHERE clauses. The SQL updates instantly.
Parameterised Queries
SELECT, INSERT, UPDATE and DELETE statements use placeholders instead of literal values: ? for MySQL and SQLite, $1, $2 for PostgreSQL and @p1, @p2 for SQL Server. Pass the actual values separately through your database driver. Never build SQL by joining user input into strings, because that allows SQL injection, one of the most common security vulnerabilities.
Database Differences Handled
| MySQL | PostgreSQL | SQL Server | SQLite | |
|---|---|---|---|---|
| Identifier quotes | `name` | "name" | [name] | "name" |
| Auto-increment key | AUTO_INCREMENT | SERIAL | IDENTITY(1,1) | AUTOINCREMENT |
| Placeholders | ? | $1 | @p1 | ? |
Safety Tips
- Always include a WHERE clause in UPDATE and DELETE statements. Without one, every row in the table is changed or removed.
- Test statements on a development database and take a backup before running changes in production.
Privacy
Statements are generated in your browser. Nothing is sent to a server or connected to any database.
Frequently Asked Questions
Which databases are supported?
MySQL and MariaDB, PostgreSQL, SQL Server and SQLite. Quoting, auto-increment syntax and placeholders change automatically.
Why are there ? or $1 symbols instead of values?
They are placeholders for parameterised queries. Your code passes the values separately, which prevents SQL injection.
Does this tool run the SQL?
No. It only generates the statement text. Run it in your database client or application.
How is the primary key chosen?
The column named in the key field becomes the primary key in CREATE TABLE and is used in WHERE clauses. Integer keys are made auto-incrementing.