Converting a database between MySQL and SQLite looks deceptively simple on the surface. After all, both speak SQL.

However, beneath the syntax lies a fundamental divergence in type systems:

  • MySQL (Static Manifest Typing): Every column has a rigid, hardware-enforced data type (INT UNSIGNED, DATETIME, VARCHAR(100), ENUM). Any attempt to insert an invalid value is rejected or coerced according to strict SQL modes.
  • SQLite (Dynamic Type Affinity): Columns do not have strict types; they have type affinities (INTEGER, REAL, TEXT, BLOB, NUMERIC). SQLite allows storing any data type in virtually any column, but interprets data based on specific affinity rules.

When converting MySQL schemas and dumps to SQLite, naive translation scripts frequently produce silent data corruption or application runtime crashes.

In this deep-dive guide, we examine the most common type traps and reveal how SQLOZ automatically handles dialect conversion on macOS.

SQLOZ Cross-Dialect Migration and Schema Comparison Diff


1. The Comprehensive MySQL-to-SQLite Type Mapping Matrix

MySQL (InnoDB) TypeTarget SQLite Storage ClassCritical Production Edge Cases & Best Practices
INT / BIGINT AUTO_INCREMENTINTEGER PRIMARY KEY AUTOINCREMENTIn SQLite, auto-incrementing primary keys must use the exact keyword INTEGER. Using INT or BIGINT prevents the rowid generator from activating!
TINYINT(1)INTEGERMySQL uses this for booleans. In SQLite, store as 0 and 1. Enforce CHECK (col IN (0, 1)) for strict data validation.
ENUM('draft', 'published')TEXT + CHECK constraintSQLite lacks an ENUM primitive. Map to TEXT with a table constraint: CHECK (status IN ('draft', 'published')).
DATETIME / TIMESTAMPTEXT (ISO-8601)SQLite lacks a native datetime class. Always format timestamps as 'YYYY-MM-DD HH:MM:SS' to allow string-based ordering and strftime() queries.
JSONTEXTMap MySQL JSON columns to SQLite TEXT. SQLite’s built-in JSON1 extension (json_extract()) works seamlessly on raw JSON text.
BLOB / LONGBLOBBLOBBinary streams map directly to SQLite BLOB. Take care with byte escaping during text dump conversions.
DECIMAL(10, 2)NUMERICStore financial values as NUMERIC to avoid floating-point rounding errors.

2. The Auto-Increment Primary Key Trap

The single most common bug when migrating to SQLite is declaring:

-- WRONG: In SQLite, this will NOT automatically generate incremental IDs!
CREATE TABLE users (
    id BIGINT PRIMARY KEY AUTOINCREMENT,
    email TEXT
);
-- Error: near "AUTOINCREMENT": syntax error

SQLite’s B-tree engine requires the exact keywords:

-- CORRECT:
CREATE TABLE users (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    email TEXT
);

In SQLite, INTEGER PRIMARY KEY binds directly to the 64-bit internal B-tree rowid.


3. The Date and Time Trap: Avoiding Timezone Drift

MySQL handles timezone offsets automatically with TIMESTAMP fields. Because SQLite stores timestamps as plain text, application queries relying on date arithmetic can produce unpredictable results if formats are inconsistent.

Best Practice: When migrating timestamps to SQLite, normalize all dates to UTC strings:

2026-09-14 18:24:00+00:00

This ensures SQLite’s date functions work reliably:

SELECT * FROM orders WHERE strftime('%Y-%m', created_at) = '2026-09';

4. How SQLOZ Automates Type Translation

Manually editing DDL statements for dozens of tables is exhausting and error-prone.

In SQLOZ, the Cross-Dialect Migration Engine:

  1. Parses your MySQL schema into an Abstract Syntax Tree (AST).
  2. Rewrites AUTO_INCREMENT definitions into valid SQLite INTEGER PRIMARY KEY AUTOINCREMENT clauses.
  3. Translates MySQL ENUM definitions into robust SQLite CHECK constraints.
  4. Normalizes dates into ISO-8601 compliant UTC text representations.
  5. Verifies schema integrity visually in the Schema Designer before data ingestion.

Summary

Migrating from MySQL to SQLite requires navigating distinct typing philosophies. By understanding type affinity and applying defensive schema constraints, you can convert databases without losing data integrity.

Download SQLOZ for macOS and let our native Apple Silicon migration engine handle dialect conversions automatically.