Skip to content

Instantly share code, notes, and snippets.

@leite08
Last active March 19, 2024 03:24
Show Gist options
  • Save leite08/80fcd6ee4de755a1e9bcddb9b008992a to your computer and use it in GitHub Desktop.
Save leite08/80fcd6ee4de755a1e9bcddb9b008992a to your computer and use it in GitHub Desktop.
Populate Postgres table w/ random data
insert into table (id, another, jsonb_data)
with data as (
select i
from generate_series(1, 1000) as g(i)
)
select
gen_random_uuid()::text,
'<insert-id-here>',
('{"dob": "' || timestamp '1940-01-01 20:00:00' + random() * (timestamp '2020-01-01 10:00:00' - timestamp '1940-01-01 20:00:00') || '", "lastName": "last' || i || '", "firstName": "first' || i || '"}')::json
from data;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment