PostgreSQL 9.3.4, ich habe eine JSON-Typ Spalte namens "Person" und die darin gespeicherten Daten im Format {dogs: [{breed: <>, name: <>}, {breed: <>, name: <>}]}
. Ich möchte die Rasse des Hundes bei Index abrufen 0. Hier sind die beiden Abfragen Ich lief:PostgreSQL Nested JSON Abfrage
nicht
db=> select person->'dogs'->>0->'breed' from people where id = 77;
ERROR: operator does not exist: text -> unknown
LINE 1: select person->'dogs'->>0->'bree...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
Works Funktioniert
select (person->'dogs'->>0)::json->'breed' from es_config_app_solutiondraft where id = 77;
?column?
-----------
"westie"
(1 row)
Warum das ist Typ Gießen notwendig? Ist es nicht ineffizient? Mache ich etwas falsch oder ist dies für Postgres JSON-Unterstützung notwendig?