Convert a MySQL schema to SQLite
Paste the CREATE TABLE statements from MySQL and ERD Designer draws them as a diagram. Change the diagram's target database to SQLite and every column's datatype is converted. You review each change before it is applied, then generate the SQLite script.
What changes in the sample
Converted to SQLite, these columns of the sample above change type. Everything else keeps its type; names, keys, nullability and lists of allowed values are left as they are.
| Column | MySQL | SQLite | Note |
|---|---|---|---|
customers.customer_id | INT identity | INTEGER | |
customers.notes | LONGTEXT | TEXT | |
customers.is_active | TINYINT(1) | BOOLEAN | |
customers.created_at | DATETIME(3) | DATETIME | default: CURRENT_TIMESTAMP(3) → CURRENT_TIMESTAMP |
orders.order_id | BIGINT identity | INTEGER | |
orders.customer_id | INT | INTEGER | |
orders.status | ENUM | VARCHAR(7) | |
orders.placed_at | TIMESTAMP | DATETIME | |
orders.receipt_pdf | MEDIUMBLOB | BLOB |
What you are asked
Where SQLite offers more than one fair answer, ERD Designer asks before it converts — once per kind of column, not once per column. For this page each question was answered with its first option:
orders.status — answered VARCHAR(7)
VARCHAR(7)— this column, held to the list by a CHECK constraintLookup table— a new table holding the values, keyed by the value itself, with a foreign key from this column
What it tells you
Where a conversion loses something, ERD Designer says so rather than picking for you. These are the messages for the sample:
- customers.created_at: SQLite timestamps take no fractional-second precision — "(3)" was dropped.
The SQLite script
This is what ERD Designer generates for the sample, for SQLite. Our test suite applies this conversion to a real SQLite server and then reads the database back to confirm it matches the diagram exactly.
PRAGMA foreign_keys=OFF;
-- Create table customers
CREATE TABLE "customers" (
"customer_id" INTEGER NOT NULL,
"email" TEXT NOT NULL,
"full_name" TEXT NOT NULL,
"notes" TEXT,
"is_active" INTEGER NOT NULL DEFAULT 1,
"created_at" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "customers_PK" PRIMARY KEY ("customer_id"),
CONSTRAINT "customers_email_uq" UNIQUE ("email")
);
-- Create table orders
CREATE TABLE "orders" (
"order_id" INTEGER NOT NULL,
"customer_id" INTEGER NOT NULL,
"status" TEXT NOT NULL DEFAULT 'new' CHECK ("status" IN ('new', 'paid', 'shipped')),
"total" NUMERIC NOT NULL,
"placed_at" TEXT NOT NULL,
"receipt_pdf" BLOB,
CONSTRAINT "orders_PK" PRIMARY KEY ("order_id"),
CONSTRAINT "orders_FK1" FOREIGN KEY ("customer_id") REFERENCES "customers" ("customer_id")
);
-- Add unique constraint on customers (email)
-- stated inside CREATE TABLE "customers" above;
-- Create index on orders (placed_at)
CREATE INDEX "orders_placed_ix" ON "orders" ("placed_at");
-- Add foreign key orders (customer_id) → customers (customer_id)
-- stated inside CREATE TABLE "orders" above;
PRAGMA foreign_keys=ON;
How to convert your own schema
- Paste your MySQL script above and press Open in ERD Designer. The diagram opens laid out and ready to edit.
- Click the diagram's name in the toolbar to open its properties, choose SQLite under Target Database / Version, and press Apply Changes.
- If SQLite offers more than one way to store a kind of column, choose one and press Continue.
- Read the list of retyped columns and any warnings, then press Apply Conversion. Save the diagram to keep it.
- Press Generate DDL (the database icon) to copy or download the SQLite script — or apply it to a database on your own network with the ERD Designer Agent.
What it reads, and what it does not
- It reads
CREATE TABLE,ALTER TABLE … ADD CONSTRAINTandCREATE INDEX: tables, columns, keys, foreign keys, unique constraints, check lists and indexes. Anything else in the script is skipped and listed. - It converts the schema, never the data: no rows are read, moved or changed.
- It does not convert views, stored procedures, functions, triggers or packages.
Which plan you need
Pasting a script and working with it as a diagram is free on the Basic plan, with no card. Converting a diagram to another database is part of the Pro and Advanced plans, which also generate its script and can apply it through the Agent.
Other conversions
- MySQL to PostgreSQL
- MySQL to Oracle
- MySQL to SQL Server
- MySQL to MariaDB
- MySQL to Amazon Redshift
- MySQL to Google BigQuery
- MySQL to Snowflake
- PostgreSQL to SQLite
- Oracle to SQLite
- SQL Server to SQLite
- MariaDB to SQLite
- Amazon Redshift to SQLite
- Google BigQuery to SQLite
- Snowflake to SQLite
Questions? Write to support@erddesigner.com. · ERD Designer · Terms · Privacy