Last active
March 19, 2024 03:24
-
-
Save leite08/80fcd6ee4de755a1e9bcddb9b008992a to your computer and use it in GitHub Desktop.
Populate Postgres table w/ random data
This file contains 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
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