Skip to content

Instantly share code, notes, and snippets.

@jdaarevalo
Created January 30, 2021 12:08
Show Gist options
  • Save jdaarevalo/cc17646bcb985c551b21edf8061c685d to your computer and use it in GitHub Desktop.
Save jdaarevalo/cc17646bcb985c551b21edf8061c685d to your computer and use it in GitHub Desktop.
second-section-fill_tables
...
-- Filling of products
INSERT INTO product
select id, concat('Product ', id)
FROM GENERATE_SERIES(1, current_setting('my.number_of_products')::int) as id;
...
...
-- Filling of cities
INSERT INTO city
select id
, concat('City ', id)
, floor(random() * (current_setting('my.number_of_coutries')::int) + 1)::int
FROM GENERATE_SERIES(1, current_setting('my.number_of_cities')::int) as id;
....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment