Toolvito

Calculates on this device. File exports run online.

Database Schema Designer

Design database tables in a simple form, or paste the CREATE TABLE statements of your database. The page draws the ER diagram, lists the keys and links, and writes the SQL for the database you use. It can also compare two schemas and write the ALTER statements between them.

Enter your values

Type one row for each column. The page writes the CREATE TABLE statements, DBML, Mermaid and a Laravel migration, and draws the diagram.

Your values

Columns

One row for each column. Tick Primary key on every column of a combined key. Refers to makes a foreign key, such as customers.id.

Your values are worked out in this browser. They are not sent to a server.

Your result will show here

Fill in the values, then choose the button below them.

Save the ER diagram as a file, or convert the SQL

Task
Save the ER diagram as SVG, PNG or PDF, with a data dictionary

The CREATE TABLE statements of the result above are read again on the server (sqlglot) and drawn as a diagram with every column, its type and its keys. A data dictionary lists the columns with their types, keys and links.

More options

The calculator above works on your device. When you run a task in this section, Toolvito receives the values and result you submit to make the file or run the check. Download the result within one hour after the job finishes. Choose Delete files now to request earlier removal. The hourly cleanup normally removes files within one to two hours after completion.

How to make an ER diagram from SQL

  1. Export the structure of your database as SQL: in MySQL Workbench, phpMyAdmin, pgAdmin, DBeaver, SQL Server Management Studio or Oracle SQL Developer choose "schema only" or "structure only"; or use pg_dump --schema-only, mysqldump --no-data or the .schema command of sqlite3.
  2. Choose Read CREATE TABLE statements, paste the SQL or open the .sql file.
  3. Press Read the SQL. The diagram is drawn below the lists of columns and links.
  4. To save the diagram as an SVG, PNG or PDF file, with a data dictionary, use the box below the result.

How to design tables

  1. Choose Design the tables in a form. Each row is one column of a table; rows with the same table name form one table.
  2. Type the type, such as integer, bigint, varchar(255), text, boolean, date, timestamp, decimal(10,2), uuid or json.
  3. Tick Primary key (on each column of a combined key), Auto number, Required or Unique. Type Refers to as table.column to make a foreign key.
  4. Choose the database and press Make the schema. Copy or download the CREATE TABLE statements, the DBML, the Mermaid text or the Laravel migration.

How the types are written

  • Each type is read into a family and written with the name each database uses: varchar(255) is NVARCHAR(255) in SQL Server and TEXT in SQLite; boolean is BIT in SQL Server; timestamp is DATETIME in MySQL and DATETIME2 in SQL Server; uuid is CHAR(36) in MySQL.
  • Auto numbers are written as GENERATED BY DEFAULT AS IDENTITY (PostgreSQL), AUTO_INCREMENT (MySQL), INTEGER PRIMARY KEY (SQLite) and IDENTITY(1,1) (SQL Server).
  • A type the page does not know is copied unchanged, and a note says so.

Comparing two schemas

Paste the old and the new CREATE TABLE statements. The page lists tables and columns added or removed, changed types, NOT NULL and defaults, keys, links and indexes, and writes the ALTER TABLE statements for your database. A renamed column shows as one removed and one added, so check the statements and back up your data before you run them.

Limits you should know

  • The page reads CREATE TABLE, ALTER TABLE ... ADD, CREATE INDEX and COMMENT ON statements. Views, triggers, functions and data are left out.
  • It does not connect to a database: export the SQL first.
  • The diagram uses crow’s foot lines; Chen notation (diamonds for relationships) is not drawn.
  • SQL is never run, so a statement can read well here and still fail in your database. Test it on a copy first.

Privacy

Your tables are read and drawn in your browser. Only when you use the box below is the SQL shown in the result sent to the Toolvito server, to draw the diagram as a file or to convert the SQL with sqlglot. Download the result within one hour after the job finishes. Choose Delete files now to request earlier removal. The hourly cleanup normally removes files within one to two hours after completion.

Related tools