Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n57gN-0005MG-Dv for pgsql-general@arkaria.postgresql.org; Wed, 05 Jan 2022 14:54:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1n57gM-00010z-Ab for pgsql-general@arkaria.postgresql.org; Wed, 05 Jan 2022 14:54:30 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n57gL-00010q-W3 for pgsql-general@lists.postgresql.org; Wed, 05 Jan 2022 14:54:29 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n57gJ-0001Jx-Jc for pgsql-general@lists.postgresql.org; Wed, 05 Jan 2022 14:54:28 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 205EsPLA041275; Wed, 5 Jan 2022 09:54:25 -0500 From: Tom Lane To: Shaozhong SHI cc: pgsql-general Subject: Re: How best to create and use associative array type in Postgres? In-reply-to: References: Comments: In-reply-to Shaozhong SHI message dated "Wed, 05 Jan 2022 12:10:50 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <41273.1641394465.1@sss.pgh.pa.us> Date: Wed, 05 Jan 2022 09:54:25 -0500 Message-ID: <41274.1641394465@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Shaozhong SHI writes: > How best to create and use associative array type in Postgres? I think the closest thing you'd find to that is jsonb, or contrib/hstore if you'd like something with a bit less complexity. The notation is unlikely to look much like Oracle, but they both have the ability to store sets of key/value pairs. https://www.postgresql.org/docs/current/datatype-json.html https://www.postgresql.org/docs/current/hstore.html regards, tom lane