Skip to content

Instantly share code, notes, and snippets.

@aaronmbos
Last active February 6, 2024 21:10
Show Gist options
  • Save aaronmbos/4e2320859251cc3fe570465dda31e18c to your computer and use it in GitHub Desktop.
Save aaronmbos/4e2320859251cc3fe570465dda31e18c to your computer and use it in GitHub Desktop.
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"}]}'
);
@joaothallis
Copy link

It's missing an ; in the end of line 6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment