Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to follow along with "Querying JSON Data in PostgreSQL" blog post
CREATE TABLE public.person
(
id integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
personb jsonb NOT NULL,
person json
)
insert into person (personb, person)
values (
'{"first_name": "Gladys", "last_name": "Perkins", "hobbies": ["Star Gazing", "Coding"]}',
'{"first_name": "Gladys", "last_name": "Perkins", "hobbies": ["Star Gazing", "Coding"]}'
);
insert into person (personb, person)
values (
'{"first_name": "Fran", "last_name": "Allen", "pets": [{"name": "Charlie", "type": "dog"}, {"name": "Marshmallow", "type": "cat"}]}',
'{"first_name": "Fran", "last_name": "Allen", "pets": [{"name": "Charlie", "type": "dog"}, {"name": "Marshmallow", "type": "cat"}]}'
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment