{"id":565,"date":"2021-03-25T00:34:55","date_gmt":"2021-03-24T15:34:55","guid":{"rendered":"http:\/\/localhost:8000\/?p=565"},"modified":"2021-03-27T13:36:27","modified_gmt":"2021-03-27T04:36:27","slug":"postgresql-json","status":"publish","type":"post","link":"http:\/\/localhost:8000\/2021\/03\/postgresql-json.html","title":{"rendered":"PostgreSQL\u306b\u304a\u3051\u308bjson\/jsonb\u578b\u306e\u53d6\u308a\u6271\u3044"},"content":{"rendered":"

PostgreSQL\u306b\u306f\u3001JSON\u30c7\u30fc\u30bf\u3092\u7ba1\u7406\u3059\u308b\u578b\u3068\u3057\u3066json\u578b\u3068jsonb\u578b\u304c\u3042\u308a\u307e\u3059\u3002
\n\u3053\u308c\u3089\u306f\u767b\u9332\u306f\u7c21\u5358\u306a\u306e\u3067\u3059\u304c\u3001\u691c\u7d22\u3057\u3066\u5229\u7528\u3059\u308b\u969b\u306f\u5c11\u3057\u7656\u304c\u3042\u308b\u306e\u3067\u3001\u89e3\u8aac\u3057\u3088\u3046\u3068\u304a\u601d\u3044\u307e\u3059\u3002<\/p>\n

PostgreSQL version: v12.6<\/p>\n

json\u578b\u3068jsonb\u578b\u306e\u9055\u3044<\/h2>\n

\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/a> \u304b\u3089\u629c\u7c8b\u3057\u307e\u3057\u305f\u3002
\n\u30ad\u30fc\u9806\u5e8f\u3084\u91cd\u8907\u3092\u5229\u7528\u3059\u308b\u3088\u3046\u306a\u7279\u6b8a\u30b1\u30fc\u30b9\u3092\u9664\u304d\u3001jsonb\u578b\u3092\u5229\u7528\u3059\u308b\u65b9\u304c\u826f\u3055\u305d\u3046\u3067\u3059\u3002<\/p>\n\n\n\n\n\n\n\n
json\u578b<\/th>\njsonb\u578b<\/th>\n<\/tr>\n<\/thead>\n
\u5165\u529b\u30c6\u30ad\u30b9\u30c8\u306e\u6b63\u78ba\u306a\u30b3\u30d4\u30fc\u3092\u683c\u7d0d
\uff08\u7a7a\u767d\u3001\u30ad\u30fc\u9806\u5e8f\u3001\u91cd\u8907\u30ad\u30fc\u306a\u3069\u3082\u4fdd\u6301\uff09<\/td>\n
\u5165\u529b\u30c6\u30ad\u30b9\u30c8\u3092\u30d1\u30fc\u30b9\u3057\u305f\u7d50\u679c\u3092\u30d0\u30a4\u30ca\u30ea\u5f62\u5f0f\u3067\u683c\u7d0d
\uff08\u7a7a\u767d\u3001\u30ad\u30fc\u9806\u5e8f\u306f\u4fdd\u6301\u3057\u306a\u3044\u3002\u91cd\u8907\u30ad\u30fc\u91cd\u8907\u30ad\u30fc\u306f\u6700\u5f8c\u306e\u5024\u3060\u3051\u3092\u4fdd\u6301\uff09<\/td>\n<\/tr>\n
\u5229\u7528\u6642\u306b\u518d\u89e3\u6790\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u305f\u3081\u3001\u5229\u7528\u6642\u306b\u6642\u9593\u304c\u304b\u304b\u308b<\/td>\n\u683c\u7d0d\u6642\u306b\u30aa\u30fc\u30d0\u30d8\u30c3\u30c9\u304c\u3042\u308b\u304c\u3001\u5229\u7528\u6642\u306f\u9ad8\u901f\u306b\u5229\u7528\u3067\u304d\u308b<\/td>\n<\/tr>\n
\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u30b5\u30dd\u30fc\u30c8\u3057\u3066\u3044\u306a\u3044<\/td>\n\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u30b5\u30dd\u30fc\u30c8\u3057\u3066\u3044\u308b<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u30c7\u30fc\u30bf\u767b\u9332<\/h2>\n

people<\/code>\u30c6\u30fc\u30d6\u30eb\u306bdetail<\/code>\u3068\u3044\u3046jsonb\u578b\u306e\u9805\u76ee\u3092\u767b\u9332\u3059\u308b\u30b5\u30f3\u30d7\u30eb\u306b\u306a\u308a\u307e\u3059\u3002
\n\u3053\u3061\u3089\u306e\u30c7\u30fc\u30bf\u3092\u5143\u306b\u5f8c\u7d9a\u306eSQL\u306e\u691c\u8a3c\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n

create table people (\n  detail jsonb\n);\ninsert into people(detail)\nvalues ('{"name": "\u592a\u90ce", "age": 35, "children": [{"name": "\u4e8c\u90ce", "age": 9}, {"name": "\u4e09\u90ce", "age": 6}]}')\n;<\/code><\/pre>\n

JSON\u6f14\u7b97\u5b50\u3067JSON\u3092\u6271\u3046<\/h2>\n

\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/a>\u3092\u5143\u306b\u89e3\u8aac\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002
\n\u6f14\u7b97\u5b50\u306f\u3001-><\/code>\u30fb->><\/code>\u30fb#><\/code>\u30fb#>><\/code>\u306e\u56db\u3064\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n

\u8a18\u53f7\u306e\u610f\u5473<\/h3>\n

JSON\u6f14\u7b97\u5b50\u306f\u3001-<\/code>\u30fb#<\/code>\u30fb><\/code>\u30fb>><\/code>\u306e\u8a18\u53f7\u306e\u7d44\u5408\u305b\u3067\u8868\u73fe\u3055\u308c\u307e\u3059\u3002
\n\u8a18\u53f7\u306b\u610f\u5473\u304c\u3042\u308b\u306e\u3067\u3001\u899a\u3048\u3066\u304a\u304f\u3068\u826f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n