Last active
October 27, 2021 23:59
-
-
Save squarism/1913c6411428057e12aef07164876aa0 to your computer and use it in GitHub Desktop.
Schemaless Postgres
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
psql=# create table schemaless ( | |
id json, | |
email json, | |
active json, | |
name json, | |
subscription json | |
); | |
CREATE TABLE | |
Table "public.schemaless" | |
Column | Type | Collation | Nullable | Default | |
--------------+------+-----------+----------+--------- | |
id | json | | | | |
email | json | | | | |
active | json | | | | |
name | json | | | | |
subscription | json | | | | |
psql=# insert into schemaless (id, email, active, name, subscription) values | |
( | |
'{"id": 42}', | |
'{"email": "[email protected]"}', | |
'{"active": true}', | |
'{"name": "Fred Flintstone"}', | |
'{"subscription": "Omega Tier!"}' | |
); | |
psql=# \x | |
Expanded display is on. | |
psql=# select * from schemaless limit 1; | |
-[ RECORD 1 ]+-------------------------------- | |
id | {"id": 42} | |
email | {"email": "[email protected]"} | |
active | {"active": true} | |
name | {"name": "Fred Flintstone"} | |
subscription | {"subscription": "Omega Tier!"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment