跳至內容
可視化

SQL 轉 ER 圖

解析 CREATE TABLE 語句並自動生成 Mermaid 格式的 ER 圖。在瀏覽器中安全地可視化您的資料庫設計。

指南: How to use & features

  • Enter or paste SQL `CREATE TABLE` statements into the text area.
  • Click the "Visualize" button to generate and display the ER diagram using Mermaid syntax.
  • Table relationships (Foreign Keys) are automatically extracted from `FOREIGN KEY` or `REFERENCES` clauses.
  • Use the "Copy Mermaid Code" button to save the generated syntax to your clipboard.
  • Your schema data is processed entirely in the browser, ensuring privacy and security.

範例: Examples

Users and Posts (One-to-Many)

輸入範例

CREATE TABLE users (
  id INT PRIMARY KEY,
  name VARCHAR(50)
);

CREATE TABLE posts (
  id INT PRIMARY KEY,
  user_id INT REFERENCES users(id),
  title VARCHAR(100)
);

輸出範例

erDiagram
    users {
        INT id PK
        VARCHAR(50) name
    }
    posts {
        INT id PK
        INT user_id
        VARCHAR(100) title
    }

    posts }|--|| users : "user_id -> id"

FAQ: FAQ

  • Does it support all SQL dialects?

    It supports standard SQL CREATE TABLE syntax. Some highly specific proprietary vendor extensions may not be fully parsed as it uses a custom regex-based parser.
  • Is my data sent to a server?

    No. All processing is done locally in your browser via JavaScript. Your SQL code never leaves your computer.
  • What if relationships are not showing up?

    Ensure that your statements include FOREIGN KEY or REFERENCES clauses. The tool relies on these constraints to identify and draw relationships.

使用情境: Common Use Cases

  • Database Documentation

    Quickly visualize and document existing table structures by pasting SQL exports.

  • Schema Design Verification

    Self-check your DDL to ensure that relationships and constraints are correctly defined during the design phase.

  • Team Collaboration

    Share specific sub-system structures with your team using lightweight Mermaid syntax before generating full documentation.

注意: Notes & Limitations

  • Limited SQL Syntax

    Statements other than CREATE TABLE (e.g., stored procedures, triggers, complex INDEX definitions) are ignored.

  • Performance with Large Schemas

    Very large schemas with dozens of tables may significantly impact browser rendering performance.

  • Syntax Errors

    Incomplete or malformed SQL statements (missing parentheses, typos) will result in parsing failures.

erDiagram USERS ||--o{ POSTS : "user_id -> id" USERS { int id PK string name } POSTS { int id PK int user_id string title }

SQL 轉 ER 圖工具

CREATE TABLE 等 SQL 定義轉成 ER 圖,視覺化 table、column 與關係。適合理解既有 schema 或建立資料庫文件。

常見用途

  • 理解 legacy schema:把 SQL 轉成視覺結構。
  • 文件化資料庫:產生 review 或指南用 ER diagram。
  • 檢查關係:查看 key 與 table 之間的連結。

未在 SQL 中明確宣告的關係或商業規則,需要人工補充與確認。

這個工具的相關文章

Recent Articles

使用案例
2026-08-04

CREATE TABLE 參考手冊|MySQL、PostgreSQL、SQLite 的型別與約束差異

以跨資料庫對照表整理 CREATE TABLE(DDL)的寫法:型別對應表、自動編號(AUTO_INCREMENT / IDENTITY / rowid)的方言差異、外鍵的 ON DELETE 行為,以及 MySQL 會靜默忽略的 CHECK 約束。

工具介紹
2026-08-03

從資料表設計自動產生 CREATE TABLE 語句的原理|DDL 產生器

解析 DDL 產生器的實作:以視覺化方式設計資料表並產生 CREATE TABLE 語句與 ER 圖。內容涵蓋 MySQL/PostgreSQL/SQLite 的型別轉換規則,以及從 JSON 範例推論欄位的演算法。

使用案例
2026-07-21

GitHub Actions needs 設計模式集|加速 CI 的依賴關係組織法與反模式

以模式與反模式對照表整理 GitHub Actions 中 needs 所建立的 job 依賴關係。涵蓋 concurrency 取消重複執行、fail-fast 取捨、matrix 與 needs 組合的陷阱,以及可重複使用工作流程,並附上可直接複製的 YAML 範例。

使用案例
2026-07-21

Mermaid ER 圖語法完全參考|關聯符號與實戰範例

完整整理 Mermaid erDiagram 語法:烏鴉腳表示法的基數對照表、一對多與多對多的差異、含 PK/FK 的屬性定義,以及一個完整的電商範例。

工具介紹
2026-07-21

如何用 SQL 建構器以視覺化方式組出 SELECT、JOIN 查詢

說明如何在瀏覽器中用視覺化 SQL 建構器組合 SELECT、WHERE、JOIN。涵蓋數值自動加引號的判斷原理、JOIN 使用時機對照表,以及多資料表 JOIN 的寫法。

使用案例
2026-07-21

SQL JOIN 完全參考|INNER、LEFT、RIGHT、FULL 的差異與結果列數觀念

以對照表與結果列數範例,完整整理 SQL 的 JOIN 種類(INNER/LEFT/RIGHT/FULL/CROSS/SELF)。說明一對多 JOIN 為何會使列數增加、WHERE 子句與 ON 子句在 NULL 判斷上的陷阱,以及多資料表 JOIN 的寫法。

廣告

廣告