The JSON column type
Half the engines give JSON a real type that validates and parses on write; the other half store text and call functions on read. Same data, very different write-time guarantees and index options.
- Family
- JSON & semi-structured
- Missing in
- None of the five
- Gotchas
- 5 listed
Engine by engine
PostgreSQL's json and jsonb, MySQL JSON and Oracle 21c+ JSON validate on write; SQL Server before 2025 and SQLite store text and validate only if you add a CHECK.
| 引擎 | 類型 | 儲存 | 備註 |
|---|---|---|---|
| SQL Server |
NVARCHAR(MAX) with ISJSON
|
Up to 2 GB | SQL Server 2025 and Azure SQL add a native json type; before that, store text, validate with ISJSON, extract with JSON_VALUE/JSON_QUERY, and index via computed columns. |
| PostgreSQL |
JSON
|
Textual, variable | The text-preserving variant: validated on write, stored exactly as sent (whitespace and duplicate keys included), and re-parsed on every read. jsonb is the faster default. |
| MySQL |
JSON
|
Binary, variable | Real JSON type since 5.7.8: validated and converted to binary on write, duplicate keys collapsed (last one wins in 8.0), partial in-place updates via JSON_SET and JSON_REPLACE. |
| SQLite |
TEXT with JSON1 functions
|
TEXT limits | No JSON type. TEXT storage, with json_valid(), json_extract() and friends (built in since 3.38, extension before); nothing stops invalid JSON in the column. |
| Oracle |
JSON type or VARCHAR2/CLOB
|
Variable, up to 32 MB (JSON type) | 21c+ has a native JSON type stored as OSON binary. From 12.1.0.2 to 19c, use VARCHAR2/CLOB/BLOB with an IS JSON check constraint for validation. |
Gotchas
Where the engines disagree. These tend to surface as bugs during a migration or a port.
- SQL Server had no JSON column type until SQL Server 2025. On 2016-2022 it is NVARCHAR(MAX) plus functions, and without a CHECK (ISJSON(col) = 1) a malformed document is only caught when a query parses it.
- PostgreSQL's json type is not the 'better' one: it re-parses on every access and keeps duplicate keys. jsonb exists precisely because json is a niche choice (exact text, key order).
- MySQL JSON columns cannot be indexed directly: index a generated column, a functional index on CAST(col->>'$.id' AS UNSIGNED) (8.0.13+), or a multi-valued index for arrays (8.0.17+).
- SQLite's JSON functions became built-in only in 3.38 (2022); on older bundled builds (PHP, old Python) they may be missing entirely, and nothing validates the column's contents either way.
- Oracle before 21c needs the IS JSON check constraint or the column is just text; without it, malformed rows insert fine and JSON_VALUE quietly returns NULL for them (its default is NULL ON ERROR).
Common questions
json or jsonb in PostgreSQL?
jsonb, almost always: it parses once on write, deduplicates keys, supports GIN indexes and containment queries. Choose json only when byte-exact text or key order must be preserved.
How do I validate JSON in SQL Server or SQLite?
SQL Server: add a CHECK (ISJSON(col) = 1) constraint. SQLite: CHECK (json_valid(col) = 1). Without it, both engines store any string in the column.
Can I index inside a JSON column?
PostgreSQL jsonb: yes, GIN indexes support containment natively. MySQL: index a generated column extracted from the JSON. SQL Server: computed column + index. SQLite: index an expression like json_extract(col, '$.id').
Map a type to the other four engines
The free type converter maps a type from one engine to its closest equivalent in the others and says where storage, precision or behaviour differ. The desktop app does the same mapping while you edit.