#04Beginner3 min

Importing SQL

Already have a database? Import your existing schema from SQL files or paste CREATE TABLE statements to generate a diagram instantly.

In this guide

  1. 1Open the Import SQL modal
  2. 2Choose file upload or paste text
  3. 3Preview the parsed tables
  4. 4Import and review the result
  5. 5Handle conflicts and warnings

Step 1: Open the Import SQL modal

In the toolbar, click the Upload icon (Import SQL). This opens the Import SQL modal. You need editor permissions to import β€” viewers will see the button as disabled.

Step 2: Choose file upload or paste text

The import modal has two tabs:

File tab: Drag and drop a .sql file onto the drop zone, or click to browse. ER Flow accepts .sql and .txt files. The file is read entirely in the browser β€” nothing is sent to a server until you click Import.

Text tab: Paste your SQL directly into the text area. This is useful when you want to import a few CREATE TABLE statements from your codebase or a database export.

ER Flow's parser supports standard SQL from PostgreSQL, MySQL, and SQLite, including:

  • CREATE TABLE with all column types and constraints
  • Inline PRIMARY KEY, UNIQUE, NOT NULL, DEFAULT
  • FOREIGN KEY ... REFERENCES with ON DELETE / ON UPDATE cascade rules
  • CREATE INDEX and CREATE UNIQUE INDEX (standalone)
  • Schema-qualified table names (e.g., public.users)
  • Quoted identifiers (double quotes, backticks, brackets)

Step 3: Preview the parsed tables

As soon as you paste or upload SQL, the parser runs immediately and shows a preview panel at the bottom of the modal. You'll see:

  • How many tables were found
  • The name of each table and how many columns it has
  • Any parse errors (highlighted in red)

This preview lets you verify the SQL was parsed correctly before importing.

Step 4: Import and review the result

Click "Import" to apply the parsed schema. ER Flow will:

  1. Create new tables for any table not already in your schema
  2. Reuse existing tables if a table with the same name already exists (adds missing columns, skips existing ones)
  3. Create foreign keys between tables, resolving references automatically
  4. Create indexes (both inline and standalone CREATE INDEX statements)
  5. Create stub tables for referenced tables that weren't included in the SQL (e.g., if a FK references a table not in the import)

All imported tables appear on the canvas at the same position β€” you'll want to arrange them after import.

Step 5: Handle conflicts and warnings

After import, you may see a success toast with warnings:

  • "Table X already exists. Imported as X_2" β€” the table name was already taken, so it was renamed
  • "Column X.y already exists with a different type. Kept the current type." β€” the column exists but with a different type; the existing type is preserved
  • "Referenced table X is not in the SQL. Created stub." β€” a FK references a table not in the import; a placeholder table was created
  • "Table X had an integer PK named id without autoincrement. Marked as autoincrement." β€” common pattern detected and auto-corrected

All imported changes can be undone with Ctrl+Z if something doesn't look right.