{"Entry":{"collection":"func","key":"jsonb-set","name":"jsonb_set","aliases":[],"metadata":{"changed_in":[],"changes":[{"descriptions_changed":false,"doc_overhaul":false,"from":"9.4","group_changed":null,"signatures":{"added":[],"removed":[]},"status":"added","to":"9.5"},{"descriptions_changed":false,"doc_overhaul":true,"from":"12","group_changed":null,"signatures":{"added":[],"removed":[]},"status":"changed","to":"13"}],"content_hash":"6002b6eb94a2891a626eb657da35aea23affe0e7c3fbb4dfd0bfed44899119d0","first_version":"9.5","group":"json","group_label":"Json Functions And Operators","groups":["json"],"imported_at":"2026-09-14T21:49:48.813589+08:00","last_version":"20","name":"jsonb_set","name_key":"jsonb_set","position":16052,"present_in":["9.5","9.6","10","11","12","13","14","15","16","17","18","19","20"],"signature":"jsonb_set ( target jsonb, path text[], new_value jsonb [, create_if_missing boolean ] ) → jsonb","signature_count":1,"slug":"jsonb-set","source_rev":"2026-09-14T13:14:25.684213+00:00@99e6866c","summary":"Returns target with the item designated by path replaced by new_value, or with new_value added if create_if_missing is true (which is the default) and the item designated by path does not exist.","summary_zh":""}},"Definition":{"Collection":"func","Key":"jsonb-set","SourceDatabase":"center","Version":"18","SourceTable":"func","SourceKey":"jsonb-set","SourceRevision":"2026-09-14T13:14:25.684213+00:00@99e6866c","Facts":{"description":"Returns target with the item designated by path replaced by new_value, or with new_value added if create_if_missing is true (which is the default) and the item designated by path does not exist. All earlier steps in the path must exist, or the target is returned unchanged. As with the path oriented operators, negative integers that appear in the path count from the end of JSON arrays. If the last path step is an array index that is out of range, and create_if_missing is true, the new value is added at the beginning of the array if the index is negative, or at the end of the array if it is positive.","description_html":"Returns \u003cem class=\"parameter\"\u003e\u003ccode\u003etarget\u003c/code\u003e\u003c/em\u003e with the item designated by \u003cem class=\"parameter\"\u003e\u003ccode\u003epath\u003c/code\u003e\u003c/em\u003e replaced by \u003cem class=\"parameter\"\u003e\u003ccode\u003enew_value\u003c/code\u003e\u003c/em\u003e, or with \u003cem class=\"parameter\"\u003e\u003ccode\u003enew_value\u003c/code\u003e\u003c/em\u003e added if \u003cem class=\"parameter\"\u003e\u003ccode\u003ecreate_if_missing\u003c/code\u003e\u003c/em\u003e is true (which is the default) and the item designated by \u003cem class=\"parameter\"\u003e\u003ccode\u003epath\u003c/code\u003e\u003c/em\u003e does not exist. All earlier steps in the path must exist, or the \u003cem class=\"parameter\"\u003e\u003ccode\u003etarget\u003c/code\u003e\u003c/em\u003e is returned unchanged. As with the path oriented operators, negative integers that appear in the \u003cem class=\"parameter\"\u003e\u003ccode\u003epath\u003c/code\u003e\u003c/em\u003e count from the end of JSON arrays. If the last path step is an array index that is out of range, and \u003cem class=\"parameter\"\u003e\u003ccode\u003ecreate_if_missing\u003c/code\u003e\u003c/em\u003e is true, the new value is added at the beginning of the array if the index is negative, or at the end of the array if it is positive.","description_zh":"","description_zh_html":"","doc":{"anchor":"FUNCTIONS-JSON-PROCESSING-TABLE","file":"functions-json.html","slug":"18"},"group":"json","group_label":"Json Functions And Operators","lang":"en","layout":"table-new","pages":["functions-json.html"],"prose_only":false,"signatures":[{"description":"Returns target with the item designated by path replaced by new_value, or with new_value added if create_if_missing is true (which is the default) and the item designated by path does not exist. All earlier steps in the path must exist, or the target is returned unchanged. As with the path oriented operators, negative integers that appear in the path count from the end of JSON arrays. If the last path step is an array index that is out of range, and create_if_missing is true, the new value is added at the beginning of the array if the index is negative, or at the end of the array if it is positive.","description_html":"Returns \u003cem class=\"parameter\"\u003e\u003ccode\u003etarget\u003c/code\u003e\u003c/em\u003e with the item designated by \u003cem class=\"parameter\"\u003e\u003ccode\u003epath\u003c/code\u003e\u003c/em\u003e replaced by \u003cem class=\"parameter\"\u003e\u003ccode\u003enew_value\u003c/code\u003e\u003c/em\u003e, or with \u003cem class=\"parameter\"\u003e\u003ccode\u003enew_value\u003c/code\u003e\u003c/em\u003e added if \u003cem class=\"parameter\"\u003e\u003ccode\u003ecreate_if_missing\u003c/code\u003e\u003c/em\u003e is true (which is the default) and the item designated by \u003cem class=\"parameter\"\u003e\u003ccode\u003epath\u003c/code\u003e\u003c/em\u003e does not exist. All earlier steps in the path must exist, or the \u003cem class=\"parameter\"\u003e\u003ccode\u003etarget\u003c/code\u003e\u003c/em\u003e is returned unchanged. As with the path oriented operators, negative integers that appear in the \u003cem class=\"parameter\"\u003e\u003ccode\u003epath\u003c/code\u003e\u003c/em\u003e count from the end of JSON arrays. If the last path step is an array index that is out of range, and \u003cem class=\"parameter\"\u003e\u003ccode\u003ecreate_if_missing\u003c/code\u003e\u003c/em\u003e is true, the new value is added at the beginning of the array if the index is negative, or at the end of the array if it is positive.","description_zh":"","description_zh_html":"","examples":[{"expr":"jsonb_set('[{\"f1\":1,\"f2\":null},2,null,3]', '{0,f1}', '[2,3,4]', false)","result":"[{\"f1\": [2, 3, 4], \"f2\": null}, 2, null, 3]"},{"expr":"jsonb_set('[{\"f1\":1,\"f2\":null},2]', '{0,f3}', '[2,3,4]')","result":"[{\"f1\": 1, \"f2\": null, \"f3\": [2, 3, 4]}, 2]"}],"html":"\u003ccode class=\"function\"\u003ejsonb_set\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003etarget\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003ejsonb\u003c/code\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003epath\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003etext[]\u003c/code\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003enew_value\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003ejsonb\u003c/code\u003e [\u003cspan class=\"optional\"\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003ecreate_if_missing\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003eboolean\u003c/code\u003e\u003c/span\u003e ] ) → \u003ccode class=\"returnvalue\"\u003ejsonb\u003c/code\u003e","returns":"jsonb","text":"jsonb_set ( target jsonb, path text[], new_value jsonb [, create_if_missing boolean ] ) → jsonb","zh_from":""}],"zh_from":""},"ManualEvidence":{"doc":{"anchor":"FUNCTIONS-JSON-PROCESSING-TABLE","file":"functions-json.html","slug":"18"}},"MeasuredEvidence":{}},"Text":{"Collection":"func","Key":"jsonb-set","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"jsonb_set","Summary":"返回target，将path指定的项替换为new_value，如果create_if_missing为真（此为默认值）并且path指定的项不存在，则添加new_value。路径中的所有前面步骤都必须存在，否则将不加改变地返回target。与面向路径的操作符一样，path中的负整数从 JSON 数组末尾计数。如果最后一个路径步骤是超出范围的数组索引，并且create_if_missing为真，那么如果索引为负，新值将添加到数组的开头，如果索引为正，则添加到数组的结尾。","BodyHTML":"返回\u003cem\u003e\u003ccode\u003etarget\u003c/code\u003e\u003c/em\u003e，将\u003cem\u003e\u003ccode\u003epath\u003c/code\u003e\u003c/em\u003e指定的项替换为\u003cem\u003e\u003ccode\u003enew_value\u003c/code\u003e\u003c/em\u003e，如果\u003cem\u003e\u003ccode\u003ecreate_if_missing\u003c/code\u003e\u003c/em\u003e为真（此为默认值）并且\u003cem\u003e\u003ccode\u003epath\u003c/code\u003e\u003c/em\u003e指定的项不存在，则添加\u003cem\u003e\u003ccode\u003enew_value\u003c/code\u003e\u003c/em\u003e。路径中的所有前面步骤都必须存在，否则将不加改变地返回\u003cem\u003e\u003ccode\u003etarget\u003c/code\u003e\u003c/em\u003e。与面向路径的操作符一样，\u003cem\u003e\u003ccode\u003epath\u003c/code\u003e\u003c/em\u003e中的负整数从 JSON 数组末尾计数。如果最后一个路径步骤是超出范围的数组索引，并且\u003cem\u003e\u003ccode\u003ecreate_if_missing\u003c/code\u003e\u003c/em\u003e为真，那么如果索引为负，新值将添加到数组的开头，如果索引为正，则添加到数组的结尾。\u003cpre\u003ejsonb_set ( target jsonb, path text[], new_value jsonb [, create_if_missing boolean ] ) → jsonb\u003c/pre\u003e返回\u003cem\u003e\u003ccode\u003etarget\u003c/code\u003e\u003c/em\u003e，将\u003cem\u003e\u003ccode\u003epath\u003c/code\u003e\u003c/em\u003e指定的项替换为\u003cem\u003e\u003ccode\u003enew_value\u003c/code\u003e\u003c/em\u003e，如果\u003cem\u003e\u003ccode\u003ecreate_if_missing\u003c/code\u003e\u003c/em\u003e为真（此为默认值）并且\u003cem\u003e\u003ccode\u003epath\u003c/code\u003e\u003c/em\u003e指定的项不存在，则添加\u003cem\u003e\u003ccode\u003enew_value\u003c/code\u003e\u003c/em\u003e。路径中的所有前面步骤都必须存在，否则将不加改变地返回\u003cem\u003e\u003ccode\u003etarget\u003c/code\u003e\u003c/em\u003e。与面向路径的操作符一样，\u003cem\u003e\u003ccode\u003epath\u003c/code\u003e\u003c/em\u003e中的负整数从 JSON 数组末尾计数。如果最后一个路径步骤是超出范围的数组索引，并且\u003cem\u003e\u003ccode\u003ecreate_if_missing\u003c/code\u003e\u003c/em\u003e为真，那么如果索引为负，新值将添加到数组的开头，如果索引为正，则添加到数组的结尾。","SourceRevision":"1b5ca64c","ContentHash":"31964e4fe6f136993315e8ce1a1bc704c8e143a073dfd5df8c61c48dd64b9642","Payload":{"description_zh":"返回target，将path指定的项替换为new_value，如果create_if_missing为真（此为默认值）并且path指定的项不存在，则添加new_value。路径中的所有前面步骤都必须存在，否则将不加改变地返回target。与面向路径的操作符一样，path中的负整数从 JSON 数组末尾计数。如果最后一个路径步骤是超出范围的数组索引，并且create_if_missing为真，那么如果索引为负，新值将添加到数组的开头，如果索引为正，则添加到数组的结尾。","description_zh_html":"返回\u003cem class=\"parameter\"\u003e\u003ccode\u003etarget\u003c/code\u003e\u003c/em\u003e，将\u003cem class=\"parameter\"\u003e\u003ccode\u003epath\u003c/code\u003e\u003c/em\u003e指定的项替换为\u003cem class=\"parameter\"\u003e\u003ccode\u003enew_value\u003c/code\u003e\u003c/em\u003e，如果\u003cem class=\"parameter\"\u003e\u003ccode\u003ecreate_if_missing\u003c/code\u003e\u003c/em\u003e为真（此为默认值）并且\u003cem class=\"parameter\"\u003e\u003ccode\u003epath\u003c/code\u003e\u003c/em\u003e指定的项不存在，则添加\u003cem class=\"parameter\"\u003e\u003ccode\u003enew_value\u003c/code\u003e\u003c/em\u003e。路径中的所有前面步骤都必须存在，否则将不加改变地返回\u003cem class=\"parameter\"\u003e\u003ccode\u003etarget\u003c/code\u003e\u003c/em\u003e。与面向路径的操作符一样，\u003cem class=\"parameter\"\u003e\u003ccode\u003epath\u003c/code\u003e\u003c/em\u003e中的负整数从 JSON 数组末尾计数。如果最后一个路径步骤是超出范围的数组索引，并且\u003cem class=\"parameter\"\u003e\u003ccode\u003ecreate_if_missing\u003c/code\u003e\u003c/em\u003e为真，那么如果索引为负，新值将添加到数组的开头，如果索引为正，则添加到数组的结尾。","signatures":[{"description_zh":"返回target，将path指定的项替换为new_value，如果create_if_missing为真（此为默认值）并且path指定的项不存在，则添加new_value。路径中的所有前面步骤都必须存在，否则将不加改变地返回target。与面向路径的操作符一样，path中的负整数从 JSON 数组末尾计数。如果最后一个路径步骤是超出范围的数组索引，并且create_if_missing为真，那么如果索引为负，新值将添加到数组的开头，如果索引为正，则添加到数组的结尾。","description_zh_html":"返回\u003cem class=\"parameter\"\u003e\u003ccode\u003etarget\u003c/code\u003e\u003c/em\u003e，将\u003cem class=\"parameter\"\u003e\u003ccode\u003epath\u003c/code\u003e\u003c/em\u003e指定的项替换为\u003cem class=\"parameter\"\u003e\u003ccode\u003enew_value\u003c/code\u003e\u003c/em\u003e，如果\u003cem class=\"parameter\"\u003e\u003ccode\u003ecreate_if_missing\u003c/code\u003e\u003c/em\u003e为真（此为默认值）并且\u003cem class=\"parameter\"\u003e\u003ccode\u003epath\u003c/code\u003e\u003c/em\u003e指定的项不存在，则添加\u003cem class=\"parameter\"\u003e\u003ccode\u003enew_value\u003c/code\u003e\u003c/em\u003e。路径中的所有前面步骤都必须存在，否则将不加改变地返回\u003cem class=\"parameter\"\u003e\u003ccode\u003etarget\u003c/code\u003e\u003c/em\u003e。与面向路径的操作符一样，\u003cem class=\"parameter\"\u003e\u003ccode\u003epath\u003c/code\u003e\u003c/em\u003e中的负整数从 JSON 数组末尾计数。如果最后一个路径步骤是超出范围的数组索引，并且\u003cem class=\"parameter\"\u003e\u003ccode\u003ecreate_if_missing\u003c/code\u003e\u003c/em\u003e为真，那么如果索引为负，新值将添加到数组的开头，如果索引为正，则添加到数组的结尾。","returns":"jsonb","text":"jsonb_set ( target jsonb, path text[], new_value jsonb [, create_if_missing boolean ] ) → jsonb","zh_from":"doc"}],"zh_from":"doc"}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","9.5","9.6"],"Locales":["en","zh-Hans"],"Signatures":[{"Version":"18","Ordinal":0,"Hash":"5d4ba4ccd037edacff160fbf64a189cf5744c3e1432acf25998f26568f8969b7","Text":"jsonb_set ( target jsonb, path text[], new_value jsonb [, create_if_missing boolean ] ) → jsonb","Returns":"jsonb","Payload":{"description":"Returns target with the item designated by path replaced by new_value, or with new_value added if create_if_missing is true (which is the default) and the item designated by path does not exist. All earlier steps in the path must exist, or the target is returned unchanged. As with the path oriented operators, negative integers that appear in the path count from the end of JSON arrays. If the last path step is an array index that is out of range, and create_if_missing is true, the new value is added at the beginning of the array if the index is negative, or at the end of the array if it is positive.","description_html":"Returns \u003cem class=\"parameter\"\u003e\u003ccode\u003etarget\u003c/code\u003e\u003c/em\u003e with the item designated by \u003cem class=\"parameter\"\u003e\u003ccode\u003epath\u003c/code\u003e\u003c/em\u003e replaced by \u003cem class=\"parameter\"\u003e\u003ccode\u003enew_value\u003c/code\u003e\u003c/em\u003e, or with \u003cem class=\"parameter\"\u003e\u003ccode\u003enew_value\u003c/code\u003e\u003c/em\u003e added if \u003cem class=\"parameter\"\u003e\u003ccode\u003ecreate_if_missing\u003c/code\u003e\u003c/em\u003e is true (which is the default) and the item designated by \u003cem class=\"parameter\"\u003e\u003ccode\u003epath\u003c/code\u003e\u003c/em\u003e does not exist. All earlier steps in the path must exist, or the \u003cem class=\"parameter\"\u003e\u003ccode\u003etarget\u003c/code\u003e\u003c/em\u003e is returned unchanged. As with the path oriented operators, negative integers that appear in the \u003cem class=\"parameter\"\u003e\u003ccode\u003epath\u003c/code\u003e\u003c/em\u003e count from the end of JSON arrays. If the last path step is an array index that is out of range, and \u003cem class=\"parameter\"\u003e\u003ccode\u003ecreate_if_missing\u003c/code\u003e\u003c/em\u003e is true, the new value is added at the beginning of the array if the index is negative, or at the end of the array if it is positive.","description_zh":"","description_zh_html":"","examples":[{"expr":"jsonb_set('[{\"f1\":1,\"f2\":null},2,null,3]', '{0,f1}', '[2,3,4]', false)","result":"[{\"f1\": [2, 3, 4], \"f2\": null}, 2, null, 3]"},{"expr":"jsonb_set('[{\"f1\":1,\"f2\":null},2]', '{0,f3}', '[2,3,4]')","result":"[{\"f1\": 1, \"f2\": null, \"f3\": [2, 3, 4]}, 2]"}],"html":"\u003ccode class=\"function\"\u003ejsonb_set\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003etarget\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003ejsonb\u003c/code\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003epath\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003etext[]\u003c/code\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003enew_value\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003ejsonb\u003c/code\u003e [\u003cspan class=\"optional\"\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003ecreate_if_missing\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003eboolean\u003c/code\u003e\u003c/span\u003e ] ) → \u003ccode class=\"returnvalue\"\u003ejsonb\u003c/code\u003e","returns":"jsonb","text":"jsonb_set ( target jsonb, path text[], new_value jsonb [, create_if_missing boolean ] ) → jsonb","zh_from":""}}],"Spellings":null,"SQLState":null,"Evidence":null}
