MySQL → PostgreSQL
Convert MySQL DECIMAL to PostgreSQL numeric
Exact-precision money and quantity columns convert one-to-one: DECIMAL(p,s) and numeric(p,s) share semantics, so no values change.
DECIMAL(p,s) → numeric(p,s)
What to know
- Precision and scale carry over exactly — DECIMAL(12,2) → numeric(12,2)
- PostgreSQL numeric allows much higher precision if you ever need it (up to 16,383 digits after the point)
- UNSIGNED DECIMAL loses only the negative-value restriction; add CHECK (col >= 0) to keep it
- Avoid float/double for money in both engines
Before / after
MySQL
CREATE TABLE orders (
total DECIMAL(12,2) NOT NULL DEFAULT 0.00
); PostgreSQL
CREATE TABLE orders (
total numeric(12,2) NOT NULL DEFAULT 0.00
); Don't convert column-by-column — convert the whole database.
Upload a dump, get back ready-to-import SQL with this mapping (and every other one) applied.
Open the MySQL → PostgreSQL converterSee the full type mapping table or all guides.