{"id":8439,"date":"2021-01-15T09:46:00","date_gmt":"2021-01-15T09:46:00","guid":{"rendered":"https:\/\/ubiq.co\/tech-blog\/?p=8439"},"modified":"2025-09-01T04:57:25","modified_gmt":"2025-09-01T04:57:25","slug":"how-to-update-array-in-postgresql","status":"publish","type":"post","link":"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/","title":{"rendered":"How to Update Array in PostgreSQL"},"content":{"rendered":"\n<p>PostgreSQL supports a vast range of data types including arrays. It provides tons of functions and operators that makes it easy to work with array data type. Sometimes you may need to update array in PostgreSQL with new data. This is commonly required in transactional databases such as that of Ecommerce sites. Updating arrays presents several interesting use cases. In this article, we will look at how to change array in PostgreSQL, modify array in PostgreSQL, and merge arrays in PostgreSQL.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/#Why_Update_Array_in_PostgreSQL\" >Why Update Array in PostgreSQL<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/#How_to_Update_Array_in_PostgreSQL\" >How to Update Array in PostgreSQL<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/#Replace_all_elements_in_an_Array\" >Replace all elements in an Array<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/#Replace_some_elements_in_an_Array\" >Replace some elements in an Array<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/#Append_and_Prepend_to_Array\" >Append and Prepend to Array<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/#Remove_array_element\" >Remove array element<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/#Merge_Arrays_in_PostgreSQL\" >Merge Arrays in PostgreSQL<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Why_Update_Array_in_PostgreSQL\"><\/span>Why Update Array in PostgreSQL<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Typically, when we need to update one or more column values, we simply use UPDATE statement. But since an array column data type contains an entire array in a single column, using UPDATE statement will not work. Updating one or more items in an array becomes even more difficult since UPDATE statement will completely overwrite the entire column value for a given row. Luckily, PostgreSQL offers many specific functions and statements that allow you to update one or more rows, append, prepend, remove or merge array items. These are really important use cases and without these functions we will have to constantly rewrite the entire final array value from scratch using UPDATE statement.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Update_Array_in_PostgreSQL\"><\/span>How to Update Array in PostgreSQL<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Here are the different ways to update array in PostgreSQL. Let us say you have the following array column.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># <code>create table employees ( <\/code>\n     <code>id int, <\/code>\n     <code>name varchar, <\/code>\n     <code>sales <strong>integer[] <\/strong><\/code>\n<code>);<\/code><\/pre>\n\n\n\n<p>In the above example, we have created column <em>sales<\/em> as an array of integers.<\/p>\n\n\n\n<p>Let us also insert data in our array column.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># insert into employees (id, name, sales)<br>          values (1, ' John Doe', ARRAY [9,7,5,4,3,2]),<br>                 (2, ' Jim Day', ARRAY [8,6,3,2,9,2]);<br><br># select * from employees;<br> id |   name    |     sales<br>----+-----------+---------------<br>  1 |  John Doe | {9,7,5,4,3,2}<br>  2 |  Jim Day  | {8,6,3,2,9,2}<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Replace_all_elements_in_an_Array\"><\/span>Replace all elements in an Array<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>PostgreSQL allows you to update all or some elements in an array. Each of these use cases requires a different approach. But in all cases you need to use UPDATE&#8230;SET statement to replace all elements of an array.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># update employees \n  set sales = '{10,12,31,10,11}' \n  where id=1;\n\n# select * from employees;\n id |   name    |      sales\n----+-----------+------------------\n  2 |  Jim Day  | {8,6,3,2,9,2}\n  1 |  John Doe | <strong>{10,12,31,10,11}<\/strong><\/pre>\n\n\n\n<p>In the above UPDATE statement, we provide array values within curly braces enclosed in single quotes. Postgres will replace the entire array for rows that match the WHERE condition. The new array can be of different length and\/or data type than the old array. The new array will completely overwrite the old one.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Replace_some_elements_in_an_Array\"><\/span>Replace some elements in an Array<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Often you may need to update specific array items. For this purpose, you will need to use update set along with the index of the item that you need to update. Here is an example to replace specific array elements as shown below.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">=# update employees\n             set <strong>sales[2] = 41<\/strong>\n             where id=1;\n\n# select * from employees;\n id |   name    |      sales\n----+-----------+------------------\n  2 |  Jim Day  | {8,6,3,2,9,2}\n  1 |  John Doe | {10,<strong>41<\/strong>,31,10,11}\n<\/pre>\n\n\n\n<p>In the above statement, we replace only the second array element by setting sales[2] value. The array item index starts from 1 and not 0. So sales[2] refers to the second array item.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Append_and_Prepend_to_Array\"><\/span>Append and Prepend to Array<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Sometimes you don&#8217;t need to update one or more items of an array but need to add one or more items before or after the array. For this, you can append and prepend values to your array using <em>array_append<\/em> and <em>array_prepend<\/em> functions respectively, as shown below. In the following query, we append 1 to the array in sales column where id=1.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># update employees\n             set sales = <strong>array_append(sales, 1)<\/strong>\n             where id=1;\n\n# select * from employees;\n id |   name    |       sales\n----+-----------+--------------------\n  2 |  Jim Day  | {8,6,3,2,9,2}\n  1 |  John Doe | {10,41,31,10,11,<strong>1<\/strong>}\n<\/pre>\n\n\n\n<p>Here is the query to prepend to an array. Here is an example to prepend 9 to the array in sales column where id=1.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># update employees\n           set sales = <strong>array_prepend(9,sales)<\/strong>\n           where id=1;\n\n# select * from employees;\n id |   name    |        sales\n----+-----------+----------------------\n  2 |  Jim Day  | {8,6,3,2,9,2}\n  1 |  John Doe | {<strong>9<\/strong>,10,41,31,10,11,1}\n<\/pre>\n\n\n\n<p>Please note, in <em>array_append<\/em>, you need to specify the value to be appended as second argument in function. In case of <em>array_prepend<\/em>, you need to specify it as the first element.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Remove_array_element\"><\/span>Remove array element<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Sometimes, you may need to remove one or more items in an array. For this, you can use <em>array_remove<\/em> function to remove element from array.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># select array_remove(sales, 9) as reduced_array from employees where id=1;\n   reduced_array\n--------------------\n {10,41,31,10,11,1}<\/pre>\n\n\n\n<p>In <em>array_remove<\/em>, you need to specify the array element that you want to remove.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Merge_Arrays_in_PostgreSQL\"><\/span>Merge Arrays in PostgreSQL<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>You may need to merge two or more arrays into a single array. You can do this in PostgreSQL using <em>array_cat<\/em> function<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># select array_cat(sales, '{9,3}') as merged_array \n           from employees where id=1;\n       merged_array\n--------------------------\n {9,10,41,31,10,11,1,9,3}\n\n# select array_cat(array[1,2],'{9,3}') as merged_array \n      from employees where id=1;\n merged_array\n--------------\n {1,2,9,3}<\/pre>\n\n\n\n<p>In <em>array_cat<\/em> function, you can pass array column or using ARRAY literal object. But please note, array_cat() can concatenate only two arrays at a time. If you want to concatenate more than 2 arrays, you need to use the output of one array_cat() as the input of another array_cat().<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">array_cat(array_cat(array1,array2),array3)<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In this article, we have learnt how to update arrays in PostgreSQL. Arrays are very useful data types for every application and updating it can be tricky. Unless you know the exact statement or function required to carry out the updating, it will become a very tedious problem for you. You can update one or more items of an array using UPDATE&#8230;SET statement. You can append, prepend, remove, merge array items using array_append(), array_prepend(), array_remove() and array_merge() functions.<\/p>\n\n\n\n<p>Need a reporting tool for PostgreSQL? <a href=\"http:\/\/ubiq.co\/\">Ubiq<\/a>&nbsp;makes it easy to visualize data in minutes, and monitor in real-time dashboards.&nbsp;<a href=\"http:\/\/ubiq.co\/accounts\/register\">Try it<\/a>&nbsp;Today!<\/p>\n\n\n\n<p>Also read:<br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-insert-into-array-in-postgresql\/\">How to Insert Into Array in PostgreSQL<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-create-array-in-postgresql\/\">How to Create Array in PostgreSQL<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-convert-string-case-in-postgresql\/\">How to Convert String Case in PostgreSQL<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you may need to update array in PostgreSQL with new data. In this article, we will look at how to change array in PostgreSQL, modify array in PostgreSQL, and merge arrays in PostgreSQL.<\/p>\n","protected":false},"author":1,"featured_media":8441,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[348],"tags":[455],"class_list":["post-8439","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-postgresql","tag-update-array"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Update Array in PostgreSQL - Ubiq BI<\/title>\n<meta name=\"description\" content=\"Sometimes you may need to update array in PostgreSQL with new data. Here is how to change array in PostgreSQL, modify array in PostgreSQL, and merge arrays in PostgreSQL.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Update Array in PostgreSQL - Ubiq BI\" \/>\n<meta property=\"og:description\" content=\"Sometimes you may need to update array in PostgreSQL with new data. Here is how to change array in PostgreSQL, modify array in PostgreSQL, and merge arrays in PostgreSQL.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/\" \/>\n<meta property=\"og:site_name\" content=\"Ubiq BI\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ubiqbi\" \/>\n<meta property=\"article:published_time\" content=\"2021-01-15T09:46:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-09-01T04:57:25+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2021\/01\/update-array-in-postgresql.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"730\" \/>\n\t<meta property=\"og:image:height\" content=\"410\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Sreeram Sreenivasan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:site\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sreeram Sreenivasan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/\"},\"author\":{\"name\":\"Sreeram Sreenivasan\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc\"},\"headline\":\"How to Update Array in PostgreSQL\",\"datePublished\":\"2021-01-15T09:46:00+00:00\",\"dateModified\":\"2025-09-01T04:57:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/\"},\"wordCount\":810,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2021\/01\/update-array-in-postgresql.webp?fit=730%2C410&ssl=1\",\"keywords\":[\"update array\"],\"articleSection\":[\"PostgreSQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/\",\"url\":\"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/\",\"name\":\"How to Update Array in PostgreSQL - Ubiq BI\",\"isPartOf\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2021\/01\/update-array-in-postgresql.webp?fit=730%2C410&ssl=1\",\"datePublished\":\"2021-01-15T09:46:00+00:00\",\"dateModified\":\"2025-09-01T04:57:25+00:00\",\"author\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc\"},\"description\":\"Sometimes you may need to update array in PostgreSQL with new data. Here is how to change array in PostgreSQL, modify array in PostgreSQL, and merge arrays in PostgreSQL.\",\"breadcrumb\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2021\/01\/update-array-in-postgresql.webp?fit=730%2C410&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2021\/01\/update-array-in-postgresql.webp?fit=730%2C410&ssl=1\",\"width\":730,\"height\":410,\"caption\":\"update array in postgresql\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/ubiq.co\/tech-blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Update Array in PostgreSQL\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#website\",\"url\":\"https:\/\/ubiq.co\/tech-blog\/\",\"name\":\"Ubiq BI\",\"description\":\"Build dashboards &amp; reports in minutes\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/ubiq.co\/tech-blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc\",\"name\":\"Sreeram Sreenivasan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"caption\":\"Sreeram Sreenivasan\"},\"description\":\"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/sreeram-sreenivasan\/\"],\"url\":\"https:\/\/ubiq.co\/tech-blog\/author\/wordpress\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Update Array in PostgreSQL - Ubiq BI","description":"Sometimes you may need to update array in PostgreSQL with new data. Here is how to change array in PostgreSQL, modify array in PostgreSQL, and merge arrays in PostgreSQL.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/","og_locale":"en_US","og_type":"article","og_title":"How to Update Array in PostgreSQL - Ubiq BI","og_description":"Sometimes you may need to update array in PostgreSQL with new data. Here is how to change array in PostgreSQL, modify array in PostgreSQL, and merge arrays in PostgreSQL.","og_url":"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/","og_site_name":"Ubiq BI","article_publisher":"https:\/\/www.facebook.com\/ubiqbi","article_published_time":"2021-01-15T09:46:00+00:00","article_modified_time":"2025-09-01T04:57:25+00:00","og_image":[{"width":730,"height":410,"url":"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2021\/01\/update-array-in-postgresql.webp","type":"image\/webp"}],"author":"Sreeram Sreenivasan","twitter_card":"summary_large_image","twitter_creator":"@UbiqBI","twitter_site":"@UbiqBI","twitter_misc":{"Written by":"Sreeram Sreenivasan","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/#article","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/"},"author":{"name":"Sreeram Sreenivasan","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"headline":"How to Update Array in PostgreSQL","datePublished":"2021-01-15T09:46:00+00:00","dateModified":"2025-09-01T04:57:25+00:00","mainEntityOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/"},"wordCount":810,"commentCount":0,"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2021\/01\/update-array-in-postgresql.webp?fit=730%2C410&ssl=1","keywords":["update array"],"articleSection":["PostgreSQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/","url":"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/","name":"How to Update Array in PostgreSQL - Ubiq BI","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/#primaryimage"},"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2021\/01\/update-array-in-postgresql.webp?fit=730%2C410&ssl=1","datePublished":"2021-01-15T09:46:00+00:00","dateModified":"2025-09-01T04:57:25+00:00","author":{"@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"description":"Sometimes you may need to update array in PostgreSQL with new data. Here is how to change array in PostgreSQL, modify array in PostgreSQL, and merge arrays in PostgreSQL.","breadcrumb":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/#primaryimage","url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2021\/01\/update-array-in-postgresql.webp?fit=730%2C410&ssl=1","contentUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2021\/01\/update-array-in-postgresql.webp?fit=730%2C410&ssl=1","width":730,"height":410,"caption":"update array in postgresql"},{"@type":"BreadcrumbList","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ubiq.co\/tech-blog\/"},{"@type":"ListItem","position":2,"name":"How to Update Array in PostgreSQL"}]},{"@type":"WebSite","@id":"https:\/\/ubiq.co\/tech-blog\/#website","url":"https:\/\/ubiq.co\/tech-blog\/","name":"Ubiq BI","description":"Build dashboards &amp; reports in minutes","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ubiq.co\/tech-blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc","name":"Sreeram Sreenivasan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","caption":"Sreeram Sreenivasan"},"description":"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.","sameAs":["https:\/\/www.linkedin.com\/in\/sreeram-sreenivasan\/"],"url":"https:\/\/ubiq.co\/tech-blog\/author\/wordpress\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2021\/01\/update-array-in-postgresql.webp?fit=730%2C410&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/pbGGTT-2c7","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8439","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/comments?post=8439"}],"version-history":[{"count":2,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8439\/revisions"}],"predecessor-version":[{"id":9377,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8439\/revisions\/9377"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media\/8441"}],"wp:attachment":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media?parent=8439"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/categories?post=8439"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/tags?post=8439"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}