Home / Guides / Generate an ER Diagram from SQL (CREATE TABLE Statements)
Generate an ER Diagram from SQL (CREATE TABLE Statements)
Skip redrawing tables by hand — paste your DDL and get a real, editable ER diagram with the relationships already wired up.
Drawing an ER diagram by hand from an existing schema is slow and error-prone — you're re-typing column names and re-drawing relationship lines that already exist, unambiguously, in the DDL. The faster path is to let the DDL generate the diagram, then spend your time on layout and review instead of data entry.
FlowDiagrams does exactly this: paste CREATE TABLE statements in, get real entity tables with crow's-foot relationship lines out — fully editable afterward, not a static image.
The three-step version
- Open FlowDiagrams and go to ☰ → Import / export SQL…
- Paste your
CREATE TABLEstatements into the Import DDL tab. - Click Build tables. Every table appears on the canvas, laid out on a grid, with foreign-key relationships already drawn as crow's-foot connectors.
A worked example
Paste this directly into the dialog to see it end to end:
CREATE TABLE customer (
customer_id INT PRIMARY KEY,
name VARCHAR(120),
email VARCHAR(200)
);
CREATE TABLE orders (
order_id INT PRIMARY KEY,
customer_id INT REFERENCES customer(customer_id),
order_date DATE,
total DECIMAL(10,2)
);
CREATE TABLE order_item (
order_item_id INT PRIMARY KEY,
order_id INT REFERENCES orders(order_id),
sku VARCHAR(40),
quantity INT
);
That produces three tables — customer, orders, order_item — with relationship lines from orders.customer_id back to customer, and from order_item.order_id back to orders. No manual connecting required.
Cleaning up after the import
Auto-layout gets the structure right; it won't always match how you'd present it. A few adjustments worth making before sharing:
- Reorder tables so related entities sit near each other — drag them; the relationship lines follow and re-route automatically.
- Add a table comment for anything non-obvious. Double-click a table to open its column editor, where each table also has a comment field that carries through to a data dictionary export later.
- Collapse noisy columns. If a table has thirty audit/metadata columns nobody needs in a review diagram, trim them in the column editor — this only affects the diagram, not any real schema.
When you don't have DDL yet
If you're designing a schema from scratch rather than documenting an existing one, skip the SQL step entirely: use the Entity toolbar (press M, or the icon in the top-right toolbar) and add tables directly with New entity table. Draw the relationships by dragging from one table's row edge to another — same crow's-foot notation, no SQL required until you're ready to export it.
Going the other direction: diagram to DDL
The same dialog works in reverse. Build or edit a diagram, then switch to Export DDL to get CREATE TABLE statements back out — useful for turning a whiteboard-style design session directly into a schema migration, without re-typing everything a second time.
Frequently asked questions
- What SQL syntax is supported for generating the diagram?
- Standard
CREATE TABLEsyntax — column definitions,PRIMARY KEY, andFOREIGN KEY/ inlineREFERENCESconstraints. Multiple statements can be pasted at once; each becomes its own table, wired together automatically wherever a foreign key points at another table in the same paste. - Can I go the other way — export a diagram back to SQL?
- Yes — the same dialog has an Export DDL tab that turns your diagram's tables back into
CREATE TABLEstatements, with a Snowflake-specific dialect option alongside generic SQL. - Does this replace a real database modelling tool?
- For fast documentation, design reviews, and onboarding — yes, and it takes seconds instead of the twenty minutes of manual box-drawing those normally cost. For deep schema design work involving indexes, partitioning strategy, or migration planning, a dedicated database modelling tool will go further.
Try it yourself
FlowDiagrams is free, works offline, and never uploads your diagram anywhere.
Open FlowDiagrams →