Skip to content

Instantly share code, notes, and snippets.

@holyketzer
Last active December 30, 2015 15:09
Show Gist options
  • Save holyketzer/7846527 to your computer and use it in GitHub Desktop.
Save holyketzer/7846527 to your computer and use it in GitHub Desktop.
PostgreSQL tricks
/* Get all sequences names */
/* select pg_get_serial_sequence('table', 'key'); */
select pg_get_serial_sequence('specializations', 'id');
/* Change sequence last value */
/* SELECT setval('sequence name', (SELECT MAX(key) FROM table)+1); */
SELECT setval('public.specializations_id_seq', (SELECT MAX(id) FROM specializations)+1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment