Skip to content

Instantly share code, notes, and snippets.

@aaronmbos
Last active February 13, 2021 04:20
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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