Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSONB available data type in mysql?

Tags:

mysql

I can't seem to find out if this is implemented in mysql? I can only find information relating to postgresql.

So, can you use JSONB in mysql or is it just JSON?

like image 843
panthro Avatar asked Feb 25 '19 14:02

panthro


People also ask

What is data type Jsonb?

The JSONB data type stores JSON (JavaScript Object Notation) data as a binary representation of the JSONB value, which eliminates whitespace, duplicate keys, and key ordering. JSONB supports GIN indexes.

Does MySQL have Jsonb?

JSON has been supported by MySQL since version 5.7. 8. MySQL stores JSON in binary form, like PostgreSQL's JSONB format. This means that the JSON is always validated, because it's always parsed, and it's efficiently accessed as it's optimized into keys with values and arrays.

Can I store JSON array in MySQL?

Note that any database will accept JSON documents as a single string blob. However, MySQL and PostgreSQL support validated JSON data in real key/value pairs rather than a basic string.


1 Answers

The main difference between the json and jsonb types in Postgres is that the latter is stored in a compressed binary format. From the MySQL documentation, it appears that MySQL's JSON type already has at least some of the behavior of Postgres' jsonb:

The JSON data type provides these advantages over storing JSON-format strings in a string column:

Optimized storage format. JSON documents stored in JSON columns are converted to an internal format that permits quick read access to document elements. When the server later must read a JSON value stored in this binary format, the value need not be parsed from a text representation. The binary format is structured to enable the server to look up subobjects or nested values directly by key or array index without reading all values before or after them in the document.

If I recall correctly, the MySQL JSON functions will still work correctly on JSON text (e.g. stored as varchar), so maybe MySQL's analogy to Postgres' json would just be storing JSON content as plain text.

like image 52
Tim Biegeleisen Avatar answered Sep 25 '22 12:09

Tim Biegeleisen