For a status column, use a short varchar with a named CHECK constraint. It works the same way in PostgreSQL, MySQL 8.0.16+, MariaDB, SQLite, SQL Server and Oracle, it shows the allowed values right in the DDL, and changing the list means swapping one constraint. Reach for a lookup table when each value carries data of its own (a label, a sort order, a flag like is_terminal) or when people outside engineering edit the list. Use a native ENUM only for a set that will never lose a value. In PostgreSQL you can't drop an enum value at all, and in MySQL the list is part of the column definition.
That is what we do in the drawDB schema gallery. Its 100 schemas have 609 columns named status, state, kind, type or role, or ending in one of those. 567 of them hold a fixed set of codes, and every one of the 567 is a varchar, nvarchar, varchar2 or text column. None is a native enum.
| Approach | Add a value | Remove a value | Values carry extra data | Works in |
|---|---|---|---|---|
varchar + CHECK | Swap the constraint | Swap the constraint | No | All six dialects |
PostgreSQL ENUM type | ALTER TYPE ... ADD VALUE | Not supported, rebuild the type | No | PostgreSQL |
MySQL ENUM column | ALTER TABLE, instant only at the end of the list | ALTER TABLE with a table copy | No | MySQL, MariaDB |
| Lookup table + foreign key | INSERT a row | DELETE a row once nothing uses it | Yes, any columns | All six dialects |
What do real status columns look like?
Small, short and stable. Across the 567 value sets in the gallery:
- Size: a median of 4 values per set. 90% have 6 or fewer, and the largest has 11. 30 sets are a plain pair like
sale | rent. - Length: the longest value in a set is typically 9 characters (
completed,suspended). The longest anywhere isnon_occupant_co_borrower, at 24. - Vocabulary: the most common values are
pending(76 sets),cancelledandactive(67 each),completed(51),expiredandfailed. - Column type:
varchar(24)210 times,varchar(16)179 times,varchar(20)121 times. 436 have a default and 570 areNOT NULL. - Sharing: only 7 sets appear in more than one column of the same schema, such as
open | closedon both GitHub issues and milestones.
Each column's note in the DBML documents its set, like 'draft | running | paused | stopped | completed', but nothing in the DDL enforces it. Writing this post, we checked every documented value against its column's length. Three could never be stored. return_of_capital is 17 characters in a varchar(16) column in the Robinhood schema, microdeposits_sent is 18 in Venmo's, and non_occupant_co_borrower is 24 in the mortgage schema's VARCHAR2(16). PostgreSQL rejects that insert with value too long for type character varying(16). We've widened all three. A CHECK constraint in the generated DDL puts the values somewhere a test can reach them. A comment never gets executed.
The A/B testing schema shows the typical shape. An experiment's status is draft | running | paused | stopped | completed, and only running experiments assign new subjects:
How do you add a CHECK constraint to a status column?
Name the constraint, so that changing it later is a DROP of a name you know rather than one the database made up. Here is the PostgreSQL version:
CREATE TABLE experiments (
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
name varchar(160) NOT NULL,
status varchar(20) NOT NULL DEFAULT 'draft',
CONSTRAINT experiments_status_check
CHECK (status IN ('draft', 'running', 'paused', 'stopped', 'completed'))
);When the list changes, swap the constraint in one transaction. Adding it NOT VALID makes PostgreSQL check new writes immediately without scanning the existing rows while holding the strong lock. VALIDATE CONSTRAINT then scans the rows under a lock that still allows reads and writes, as the ALTER TABLE docs describe:
BEGIN;
ALTER TABLE experiments DROP CONSTRAINT experiments_status_check;
ALTER TABLE experiments ADD CONSTRAINT experiments_status_check
CHECK (status IN ('draft', 'scheduled', 'running', 'paused', 'stopped', 'completed'))
NOT VALID;
COMMIT;
ALTER TABLE experiments VALIDATE CONSTRAINT experiments_status_check;MySQL uses the same syntax, but it only enforces CHECK from 8.0.16 onward. Earlier versions parse the constraint and ignore it, so on 5.7 the constraint protects nothing. MariaDB has enforced it since 10.2.1.
CREATE TABLE experiments (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(160) NOT NULL,
status VARCHAR(20) NOT NULL DEFAULT 'draft',
CONSTRAINT experiments_status_check
CHECK (status IN ('draft', 'running', 'paused', 'stopped', 'completed'))
);
ALTER TABLE experiments DROP CHECK experiments_status_check;
ALTER TABLE experiments ADD CONSTRAINT experiments_status_check
CHECK (status IN ('draft', 'scheduled', 'running', 'paused', 'stopped', 'completed'));SQL Server and Oracle accept the same CONSTRAINT ... CHECK (status IN (...)) clause and change it with ALTER TABLE ... DROP CONSTRAINT. SQLite enforces CHECK too, but its ALTER TABLE can't add or drop a constraint, so changing the list means rebuilding the table: create the new table, copy the rows, drop the old one, rename. On SQLite, that is one reason to leave room in the list up front or to use a lookup table.
SQLite has a second quirk that makes the CHECK matter more there. It ignores the length in varchar(16), so without a constraint a typo like 'canceled' or a 300-character string goes into a status column without complaint.
When should you use a native ENUM type?
When the set is closed for good: days of the week, a card suit, a protocol's fixed message types. Product statuses are rarely like that. A billing state machine that starts as trialing | active | cancelled picks up past_due and paused within a year, and sometimes loses one.
In PostgreSQL, an enum is its own type:
CREATE TYPE experiment_status AS ENUM ('draft', 'running', 'paused', 'stopped', 'completed');
CREATE TABLE experiments (
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
status experiment_status NOT NULL DEFAULT 'draft'
);
ALTER TYPE experiment_status ADD VALUE 'scheduled' BEFORE 'running';
ALTER TYPE experiment_status RENAME VALUE 'stopped' TO 'halted';Adding and renaming are catalog-only changes. Two things bite. First, there is no DROP VALUE. Removing one means a new type and an ALTER COLUMN ... TYPE that rewrites every table using it, or renaming the value to something like deprecated_stopped and forbidding it with a CHECK, which is the workaround Cybertec recommends. Second, a value added inside a transaction can't be used until that transaction commits. Run the ADD VALUE and a backfill that uses the new value in one migration, and PostgreSQL 16 stops it with unsafe use of new value "scheduled" of enum type experiment_status. The ALTER TYPE docs cover both limits.
What you get in return is compact storage: four bytes per value however long the label is, and sorting in declaration order. For a 9-character code the space saving is a handful of bytes per row, which doesn't justify the migration cost.
In MySQL and MariaDB, the list lives in the column definition:
CREATE TABLE experiments (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
status ENUM('draft', 'running', 'paused', 'stopped', 'completed') NOT NULL DEFAULT 'draft'
);MySQL stores the index of the value, not the string, and that leaks out in three places. ORDER BY status sorts by list position, not alphabetically. Outside strict SQL mode, an invalid value is stored as the empty string '' with a warning instead of failing. And because each column carries its own list, two tables that share a status set have to be kept in sync by hand. Adding a value at the end of the list can be an instant change. Inserting one in the middle, reordering or removing one copies the table.
SQL Server and SQLite have no enum type, so a CHECK constraint is the only option. Oracle added enumeration domains in 23ai, but their names must be SQL identifiers and they store numbers, so they don't map to a varchar status column. A CHECK works on every Oracle version.
When does a lookup table beat a CHECK constraint?
When a value is a row of data rather than a word. The test is whether you keep wanting a second column about the value: a display label, a position in a dropdown, a colour, whether the state is terminal, whether it counts toward a quota. With a CHECK, those facts end up scattered through application code, in a switch statement in every service that renders or filters the status.
The gallery's clearest case is Airbnb's amenities table. Each amenity has a stable code for filters, a guest-facing name, a category that groups it on the listing page and an is_safety flag, because some safety items must be disclosed by law. That is four facts per value, and hosts pick amenities from a list that grows without a deploy:
If you do build a lookup table for a status, key it on the code itself, not a numeric id:
CREATE TABLE order_statuses (
code varchar(24) PRIMARY KEY,
label varchar(60) NOT NULL,
sort_order smallint NOT NULL,
is_terminal boolean NOT NULL DEFAULT false
);
INSERT INTO order_statuses (code, label, sort_order, is_terminal) VALUES
('pending', 'Pending', 1, false),
('paid', 'Paid', 2, false),
('shipped', 'Shipped', 3, false),
('delivered', 'Delivered', 4, true),
('cancelled', 'Cancelled', 5, true);
CREATE TABLE orders (
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
status varchar(24) NOT NULL DEFAULT 'pending'
REFERENCES order_statuses (code) ON UPDATE CASCADE,
placed_at timestamptz NOT NULL DEFAULT now()
);
CREATE INDEX orders_status_idx ON orders (status);The text key keeps orders.status readable in every query, log line and backup, with no join needed to tell what a row means. It also avoids the problem Cybertec measured with a smallint key in PostgreSQL. When you filter on the label through a join, the planner doesn't know which id the label maps to, so its row estimate falls back to an average. With a text key, WHERE status = 'shipped' uses the column's own statistics. ON UPDATE CASCADE turns a renamed code into one statement. The cost is the foreign key check on every insert and update, a primary key lookup in a table of five rows.
What if two columns share the same value set?
Use a domain in PostgreSQL. The status page schema stores operational | degraded_performance | partial_outage | major_outage | under_maintenance twice: the component's current status and each row of its history. A domain gives both columns one definition you can still change:
CREATE DOMAIN component_status AS varchar(24)
CONSTRAINT component_status_check
CHECK (VALUE IN ('operational', 'degraded_performance', 'partial_outage',
'major_outage', 'under_maintenance'));
CREATE TABLE components (
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
current_status component_status NOT NULL DEFAULT 'operational'
);
CREATE TABLE component_status_history (
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
component_id bigint NOT NULL REFERENCES components (id) ON DELETE CASCADE,
status component_status NOT NULL
);
ALTER DOMAIN component_status DROP CONSTRAINT component_status_check;
ALTER DOMAIN component_status ADD CONSTRAINT component_status_check
CHECK (VALUE IN ('operational', 'degraded_performance', 'partial_outage',
'major_outage', 'under_maintenance', 'unknown')) NOT VALID;Unlike an enum, a domain constraint can be dropped and re-added like any other, so the list can shrink. In MySQL, SQL Server and SQLite, which have no domains, repeat the CHECK on each column or move the set into a lookup table that both columns reference. Seven shared sets in 100 schemas suggests this comes up less often than the enum-versus-table debate implies.
What can a CHECK constraint do that neither alternative can?
Relate the status to the rest of the row. A status usually implies other facts: a shipped order has a tracking number, a cancelled one has a reason. Neither an enum nor a foreign key can say that. A CHECK can:
CREATE TABLE shipments (
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
status varchar(16) NOT NULL DEFAULT 'packed'
CONSTRAINT shipments_status_check
CHECK (status IN ('packed', 'shipped', 'delivered', 'returned')),
tracking_number varchar(40),
shipped_at timestamptz,
CONSTRAINT shipments_shipped_fields_check
CHECK (status = 'packed' OR (tracking_number IS NOT NULL AND shipped_at IS NOT NULL))
);That second constraint does more for data quality than the choice between the three approaches. It works with a lookup table or an enum too, so you can combine them.
What SQL does drawDB generate for each option?
In the editor, each column has a Check expression field. Type status IN ('draft', 'running', 'paused', 'stopped', 'completed') and every exporter writes it inline as CHECK(...) for PostgreSQL, MySQL, MariaDB, SQLite, SQL Server and Oracle. A lookup table is an ordinary table with a relationship, so it exports as a REFERENCES clause in every dialect.
For native enums, it depends on the diagram's database. A MySQL or MariaDB diagram has an ENUM column type that exports as ENUM('draft', 'running', ...) in the column. A PostgreSQL diagram has an Enums tab, and each enum you define there exports as one named CREATE TYPE ... AS ENUM that any number of columns can use. A generic diagram, which you choose when you haven't picked a database yet, translates an ENUM column when you export it:
| Export target | What a generic ENUM column becomes |
|---|---|
| MySQL, MariaDB | ENUM("draft", "running", ...) inline |
| PostgreSQL | CREATE TYPE "status_t" AS ENUM (...), named after the column |
| SQLite | TEXT CHECK("status" in ('draft', 'running', ...)) |
| SQL Server | NVARCHAR(255) CHECK([status] in ('draft', 'running', ...)) |
The PostgreSQL row has a catch: the type is named after the column, so two tables that each have an enum column called status both export CREATE TYPE "status_t", and the second fails with type "status_t" already exists. If your schema will end up on PostgreSQL, switch the diagram to PostgreSQL and define the enums once in the Enums tab. Better still, use a varchar with a check expression and skip the type entirely.
To compare all three on a real schema, open the A/B testing example in the editor, add a check expression to experiments.status, and export the SQL for your database. If you're still deciding on the rest of the conventions, our schema design best practices audit covers naming, keys, money and timestamps across the same 100 schemas.
Frequently asked questions
Is a lookup table with a smallint id faster than a text status column?
Rarely enough to matter for a status column. Status values are short (the longest value in a typical gallery set is 9 characters), PostgreSQL deduplicates repeated B-tree keys, and Cybertec measured the same table size for an enum and a smallint key because of row alignment padding. The smallint key also costs you a join on every read and worse row estimates in PostgreSQL. Key the lookup table on the text code instead.
How do I remove a value from a PostgreSQL enum?
There is no ALTER TYPE ... DROP VALUE. Either create a new type without the value, change every column with ALTER COLUMN ... TYPE new_type USING col::text::new_type (a full table rewrite under an ACCESS EXCLUSIVE lock), drop the old type and rename the new one, or rename the old value to something like 'deprecated_x' and add a CHECK constraint that forbids it. The second is the one you can run on a busy table.
Do ORMs create a CHECK constraint for enum fields?
Mostly not. Prisma maps an enum block to a native PostgreSQL enum and has no way to declare a CHECK constraint in its schema. Rails enums store integers with no constraint unless you add add_check_constraint in a migration, and Django choices are validated only in Python unless you add a CheckConstraint to Meta.constraints. Write the constraint in a migration yourself.
Should the status values be lowercase codes or display labels?
Codes: lowercase snake_case like past_due or cancelled_by_host, which never change once code depends on them. Labels belong in the application's translation files or in a label column on a lookup table. Storing 'Past due' means a copy edit becomes a data migration, and a translated UI cannot use the stored value anyway.
Can a CHECK constraint reference another table?
No. CHECK constraints in PostgreSQL, MySQL, SQLite, SQL Server and Oracle can only see the row being written. If the allowed values live in another table, that is what a foreign key is for. A CHECK can, however, combine columns of the same row, for example requiring shipped_at to be set whenever status is 'shipped', which neither an enum nor a lookup table can express.
