How to use SQL DDL to ER Diagram
- Paste supported CREATE TABLE declarations, including every referenced table.
- Declare foreign keys explicitly. Referenced columns must exist and match an ordered PRIMARY KEY or UNIQUE group in the supplied declarations.
- Read the declared-key report. Download schema-diagram.svg, schema-diagram.mmd and schema-name-map.json as needed.
- Keep the name map with Mermaid edits, and review the original SQL separately before running any database change.
Example: SQL DDL to ER Diagram
Diagram customers and orders with one declared customer_id foreign key.
Options
- Column and key subset
- Use plain INT/INTEGER, SMALLINT, BIGINT, REAL, DOUBLE PRECISION, NUMERIC, DECIMAL, CHAR, VARCHAR, TEXT, BOOLEAN, DATE, TIMESTAMP, UUID or BYTEA types. Supported declarations include NOT NULL and primary, unique or foreign keys, including grouped keys. Unknown clauses are refused.
- Declared relationships
- Foreign-key declarations create diagram edges. Similar column names do not create relationships, and the tool does not infer cardinality, optionality or data counts. Include both sides of each relationship in the supplied SQL.
- Diagram exports
- The SVG shows original names. Mermaid uses class-diagram syntax and generated table/field identifiers; schema-name-map.json maps them back to the original names. These exports do not create or migrate a database.
Supported inputs and limits
- A strict PostgreSQL-like CREATE TABLE subset: up to 100,000 UTF-8 bytes, 12 tables, 120 total columns, 40 foreign keys and 12,000 tokens.
- Identifiers accept a bounded ASCII grammar; schema-qualified names, backticks, defaults, CHECK, named constraints, generated expressions, indexes, ALTER and dialect options are refused.
- SVG height is limited to 8,000 pixels and combined SVG/Mermaid source to 1,000,000 UTF-8 bytes.
- No SQL runs, database connection, full dialect validation or inferred cardinality is provided.
Where your input is processed
This tool does not upload your inputs. See the limits for anything saved on your device.
Keep original names with the diagram
The SVG displays original names, while Mermaid uses generated identifiers and a separate name map. Include that mapping when adapting the Mermaid source. A relationship picture can help review a schema draft, but it does not run migrations, inspect existing data or prove that a database currently enforces the constraints.
Questions about SQL DDL to ER Diagram
Does this run the SQL?
No. It reads supported declarations in the browser.
Are all database dialects supported?
No. Unsupported types, constraints or statement forms are refused.
Where do the relationship lines come from?
Only declared foreign keys create relationships; the tool does not infer row counts or business rules.