Last active
June 30, 2018 16:20
-
-
Save yihyang/cb61f0b2f4f6b41c43faff67f64619a0 to your computer and use it in GitHub Desktop.
SQL CheatSheet
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
| # FOR LOOP - SQL | |
| do $$ | |
| begin | |
| for r in 1..100000 loop | |
| insert into events(id,location_id, status) values(r,1,'ACTIVE'); | |
| end loop; | |
| end; | |
| $$; | |
| # LOOP INSERT | |
| INSERT INTO public.events(location_id, number_of_hosts) | |
| SELECT id AS location_id, 10 AS number_of_hosts, FROM events ORDER BY id ASC LIMIT 1 OFFSET 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment