GoDrawGoDraw

Export SQL

Stable

From 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.

The Export SQL modal showing a live DDL preview and a dialect selector
The Export SQL modal: pick a dialect, preview the DDL, then copy or download

How it works

1

Build ER tables

Model your entities with columns, data types, and keys. Draw crow's-foot relationship arrows between columns to define foreign keys.

2

Choose a dialect

Open Export SQL and pick Postgres, MySQL, or SQLite. The DDL preview regenerates live as you switch.

3

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.

DialectIdentifier quotingNotable 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.

DDL output showing CREATE TABLE blocks followed by ALTER TABLE foreign keys
CREATE TABLE blocks first, foreign keys as ALTER TABLE statements

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)
);
The Import SQL schema modal with pasted DDL and a tables/relationships summary
Paste or load DDL; GoDraw rebuilds the tables and relationships

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.

Was this helpful?