Export SQL
StableFrom diagram to database.
Export ER table schemas as CREATE TABLE statements across multiple SQL dialects, and import SQL back into ER tables.
What it does
ER tables export to runnable SQL. GoDraw reads your ER tables
and the relationship arrows drawn between them, then generates CREATE TABLE
statements (including keys, constraints, and foreign keys) in your chosen
dialect. It also works in reverse: paste an existing schema and GoDraw rebuilds
the tables and relationships on the canvas.
The SQL button in the export dialog is only enabled once at least one ER table exists on the board.
How it works
Build ER tables
Model your entities with columns, data types, and keys. Draw crow's-foot relationship arrows between columns to define foreign keys.
Choose a dialect
Open Export SQL and pick Postgres, MySQL, or SQLite. The DDL preview regenerates live as you switch.
Copy or download
Copy the DDL to your clipboard or Download .sql. To go the other way, open the import modal and paste a schema.
Dialects
GoDraw supports three SQL dialects. Column types are free text, so each dialect
normalizes the common base types and passes anything unknown through verbatim;
explicit lengths you typed (e.g. varchar(100), decimal(10,2)) are preserved.
| Dialect | Identifier quoting | Notable type handling |
|---|---|---|
| PostgreSQL (default) | "double quotes" | datetime → timestamp, blob → bytea, native uuid/jsonb; enums become a CREATE TYPE |
| MySQL | `backticks` | boolean → tinyint(1), uuid → char(36); bare varchar gets a default (255); native inline enum(...) |
| SQLite | "double quotes" | Collapses to integer / real / numeric / text; enums become text + a CHECK (... IN (...)) |
Generated DDL
Tables are emitted first, then foreign keys as separate ALTER TABLE statements.
This sidesteps table-ordering and circular-dependency problems. Foreign-key
direction is derived from the crow's-foot heads (the "many" end becomes the child
side). Anything that can't be modeled cleanly is surfaced as a -- comment
rather than silently dropped.
-- Generated by GoDraw (PostgreSQL)
CREATE TABLE users (
id integer NOT NULL,
email varchar UNIQUE,
PRIMARY KEY (id)
);
CREATE TABLE orders (
id integer NOT NULL,
user_id integer,
PRIMARY KEY (id)
);
-- Foreign keys
ALTER TABLE orders ADD CONSTRAINT fk_orders_user_id
FOREIGN KEY (user_id) REFERENCES users (id);
Note
Enums adapt to the dialect: MySQL inlines enum('a','b'), Postgres emits a
CREATE TYPE ... AS ENUM (...) before the tables, and SQLite falls back to
text with a CHECK constraint. Many-to-many relationships can't map to a
single FK, so GoDraw emits a commented junction-table stub for you to fill in.
Import SQL
Import is the mirror image of export. Open the Import SQL schema dialog,
paste your DDL (or load a .sql / .ddl / .txt file), and GoDraw parses it
into tables and crow's-foot relationships on the canvas.
The parser is a lightweight, forgiving tokenizer, not a full SQL grammar. It
tolerates Postgres, MySQL, and SQLite DDL: quoted, backtick, and bracket
identifiers; inline and table-level foreign keys; and ALTER TABLE ADD FOREIGN KEY. It never throws: anything it can't model becomes a warning you can review
before importing. The footer shows a live count of tables and relationships
detected.
CREATE TABLE users (
id int PRIMARY KEY,
email varchar UNIQUE
);
CREATE TABLE orders (
id int PRIMARY KEY,
user_id int REFERENCES users(id)
);
Tip
Define primary and foreign keys in your ER diagram so the exported SQL includes the right constraints. To export only part of a diagram, select the tables you want and right-click → Copy as SQL. Relationship arrows whose both ends sit in the selection are included automatically.