O'Reilly logo

MySQL 8 Cookbook by Karthik Appigatla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using JSON

As you have seen in the previous chapter, to store data in MySQL, you have to define the database and table structure (schema), which is a major limitation. To cope with that, from MySQL 5.7, MySQL supports the JavaScript Object Notation (JSON) datatype. Earlier there was no separate datatype and it was stored as a string. The new JSON datatype provides automatic validation of JSON documents and optimized storage format.

JSON documents are stored in binary format, which enables the following:

  • Quick-read access to document elements
  • No need for the value to be parsed from a text representation when the server reads the JSON again
  • Looking up subobjects or nested values directly by key or array index without reading all values before ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required