MySQL → PostgreSQL
Convert MySQL SET to PostgreSQL arrays
PostgreSQL has no SET type. The natural mapping is a text array (text[]), which supports the same "multiple choices from a list" idea with far better querying.
SET → text[]
What to know
- SET('a','b','c') → text[]; 'a,c' becomes '{a,c}'
- Membership tests: 'a' = ANY(tags) replaces FIND_IN_SET
- A GIN index on the array makes membership queries fast
- To keep label validation, add a CHECK with <@ (contained in) against the allowed set
Before / after
MySQL
CREATE TABLE articles (
flags SET('draft','featured','archived')
); PostgreSQL
CREATE TABLE articles (
flags text[]
);
-- query: WHERE 'featured' = ANY(flags) 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.