Commit 5d056f69 authored by Gaetan Carabetta's avatar Gaetan Carabetta
Browse files

update json

parent 2ffbb9e0
......@@ -28,12 +28,22 @@ INSERT INTO animal VALUES (
"medicaments":[
{
"nom": "LEVOTHYROX",
"posologie":
{
"debut": "2019-06-17",
"duree": 10,
"quantité": 4
}
},
{
"nom": "DOLIPRANE",
"posologie":
{
"debut": "2019-06-17",
"duree": 10,
"quantité": 3
}
}
]
},
{
......@@ -45,16 +55,31 @@ INSERT INTO animal VALUES (
"medicaments":[
{
"nom": "LEVOTHYROX",
"posologie":
{
"debut": "2019-06-17",
"duree": 10,
"quantité": 4
}
},
{
"nom": "DOLIPRANE",
"posologie":
{
"debut": "2019-06-17",
"duree": 10,
"quantité": 3
}
},
{
"nom": "LEVOTHYROX",
"posologie":
{
"debut": "2019-06-17",
"duree": 10,
"quantité": 2
}
}
]
}
]', 1,'lapin');
......@@ -73,12 +98,22 @@ INSERT INTO animal VALUES (
"medicaments":[
{
"nom": "IMODIUM",
"posologie":
{
"debut": "2019-06-17",
"duree": 10,
"quantité": 2
}
},
{
"nom": "FORLAX",
"posologie":
{
"debut": "2019-06-17",
"duree": 10,
"quantité": 3
}
}
]
}
]', 2,'lapin');
......@@ -96,8 +131,13 @@ INSERT INTO animal VALUES (
"medicaments":[
{
"nom": "PLAVIX",
"posologie":
{
"debut": "2019-06-17",
"duree": 10,
"quantité": 2
}
}
]
}
]', 3,'hamster');
/*
Exemple de requête pour récupérer des éléments
d'un tableau dans un tableau JSON
*/
select m->>'nom'
from animal a, json_array_elements(a.traitements) t, json_array_elements(t->'medicaments') m;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment