SQL Export
Export your schema as production-ready CREATE TABLE statements.
Steps
- Click Export in the top-right of the ERD panel
- Select SQL
- Choose your target dialect: PostgreSQL, MySQL, SQLite, or MSSQL
- Click Download — a
.sqlfile downloads
What's included
CREATE TABLEstatements for all tablesPRIMARY KEYconstraintsFOREIGN KEYconstraints withON DELETE/ON UPDATErulesUNIQUEconstraintsNOT NULLconstraintsDEFAULTvaluesCREATE TYPE(enums — PostgreSQL only)AUTO_INCREMENT/SERIAL/IDENTITYfor auto-increment PKs
PostgreSQL example
CREATE TYPE carbon_tier AS ENUM ('A', 'B', 'C', 'D');
CREATE TYPE order_status AS ENUM ('pending', 'confirmed', 'processing', 'shipped', 'delivered', 'cancelled');
CREATE TABLE suppliers (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
carbon_tier carbon_tier NOT NULL DEFAULT 'C',
country VARCHAR(100),
is_active BOOLEAN NOT NULL DEFAULT TRUE,
created_at TIMESTAMP NOT NULL DEFAULT NOW()
);
CREATE TABLE products (
id SERIAL PRIMARY KEY,
supplier_id INTEGER NOT NULL,
name VARCHAR(255) NOT NULL,
sku VARCHAR(100) NOT NULL UNIQUE,
carbon_intensity_score DECIMAL(5,2) NOT NULL DEFAULT 0,
unit_price DECIMAL(10,2) NOT NULL DEFAULT 0,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
FOREIGN KEY (supplier_id) REFERENCES suppliers(id) ON DELETE RESTRICT
);
Running the exported SQL
The exported file can be run directly:
# PostgreSQL
psql -U username -d database_name -f schema.sql
# MySQL
mysql -u username -p database_name < schema.sql