MySQL 8.0: From SQL Tables to JSON Documents

 MySQL 8.0: From SQL Tables to JSON Documents


One of the nice things about MySQL 8.0 is the ability to combine the relational and document models. As a developer, you can choose to work with traditional SQL tables, with schemaless JSON documents, or with both types at the same time. Here we show how to bridge SQL tables and JSON documents by using JSON functions. Enjoy!


Step.1.Create sample database.


step.2.create table insert record.

step.3.From an SQL Table to a JSON Document


Here we use two JSON aggregation functions called JSON_ARRAYAGG() and JSON_OBJECT(). We simply select from employees and convert the result set into JSON like this:


step.4.We now have a JSON Document referenced by the variable @jsonempl. Let us look at it using the JSON_PRETTY() function:



step.5. Now sql also.







Comments

Popular posts from this blog

MySQL Point in Time Recovery: How To Configure And How Does it Work?

MySQL Replication Switchover: Step-by-Step Guide

Mysql Commercial Mysqlbackup:How to take Differential or Incremental Backup and resotre using mysqlbackup utility in mysql 8.0.37 enterprise edition