From: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
---|---|
To: | Kavi <kaviraj125(at)gmail(dot)com> |
Cc: | pgsql-novice(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org, PostgreSQL mailing lists <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: [GENERAL] JSON TO POSTGRE TABLE |
Date: | 2015-03-30 10:11:47 |
Message-ID: | CAB7nPqTz4X53yZF61A5GpDHqROR5zTK_0NT7gh94f0horiXa4Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-novice pgsql-sql |
On Mon, Mar 30, 2015 at 6:54 PM, Kavi <kaviraj125(at)gmail(dot)com> wrote:
>
> I sample data as below-
>
>
> {
> "glossary": {
> "title": "example glossary",
> "GlossDiv": {
> "title": "S",
> "GlossList": {
> "GlossEntry": {
> "ID": "SGML",
> "SortAs": "SGML",
> "GlossTerm": "Standard Generalized Markup Language",
> "Acronym": "SGML",
> "Abbrev": "ISO 8879:1986",
> "GlossDef": {
> "para": "A meta-markup language, used to create markup languages such as DocBook.",
> "GlossSeeAlso": ["GML", "XML"]
> },
> "GlossSee": "markup"
> }
> }
> }
> }
> }
>
> how can i inerst these json data in postgre tables.
>
> .ie I want to convert json into sql as per the field
>
> This may have been better asked in pgsql-novice I guess...
JSON is a data type:
http://www.postgresql.org/docs/devel/static/datatype-json.html
So what you need to do is at least to create a table with a column having
as data type JSON, and then insert data into it:
=# CREATE TABLE json_tab (data json);
CREATE TABLE
=# INSERT INTO json_tab VALUES ('{"key":"value","key2":"value2"}');
INSERT 0 1
=# select * from json_tab ;
data
---------------------------------
{"key":"value","key2":"value2"}
(1 row)
--
Michael
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2015-03-30 10:13:11 | Re: JSON TO POSTGRE TABLE |
Previous Message | Alban Hertroys | 2015-03-30 10:03:21 | Re: pgadmin3 installation on Oracle Linux 6.6 64-bit ? |
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2015-03-30 10:13:11 | Re: JSON TO POSTGRE TABLE |
Previous Message | Kavi | 2015-03-30 09:54:25 | JSON TO POSTGRE TABLE |
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2015-03-30 10:13:11 | Re: JSON TO POSTGRE TABLE |
Previous Message | Kavi | 2015-03-30 09:54:25 | JSON TO POSTGRE TABLE |