Native JSON column with functions JSON_EXTRACT, ->, ->> (5.7+), and generated columns for indexing.
Store and query
CREATE TABLE configs (
id INT AUTO_INCREMENT PRIMARY KEY,
body JSON NOT NULL
);
INSERT INTO configs (body) VALUES ('{"theme":"dark","beta":true}');
SELECT id, body->>'$.theme' AS theme FROM configs WHERE body->>'$.beta' = 'true';Practice: Run on practice.
Compare Postgres JSONB
Postgres JSONB indexing is richer—see PostgreSQL when JSON queries dominate.
Important interview questions and answers
- Q: -> vs ->>?
A: -> returns JSON; ->> returns unquoted SQL string. - Q: Validate JSON?
A: Invalid JSON rejected on insert into JSON column.
Self-check
- Extract theme from body JSON.
- Difference -> and ->>?
Tip: Use ->> for string comparisons in WHERE.
Interview prep
- ->> ?
Returns unquoted scalar from JSON path.
- Invalid JSON?
Insert rejected into JSON column.