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 Replication Switchover: Step-by-Step Guide

How to create database manually in oracle 11g R2

How To Install and Configure Innodb Cluster /shell/Router