Skip to content

JSON

JSON is one of the most commonly-used formats for aggregating data. To insert a JSON field in an SQL table we use

CREATE TABLE <name>(
    ...
    <parameter_name> JSON
    ...
)

Example

INSERT INTO Doctor (Did, Dname, Degree) VALUES
(1234, 'Jai Kishan', "Degree":[
    {"First_Degree": "MS", "Dept": "Chemistry"}
    {"Second_Degree": "MCH", "Dept": "Physics"}
])

SELECT Did, Degree->First_Degree as Degree FROM Doctor 

will yield (1234, MS)