Skip to content

Instantly share code, notes, and snippets.

@sany2k8
Last active April 1, 2017 07:20
Show Gist options
  • Save sany2k8/6ee5914b0b54bf3826798623501c7457 to your computer and use it in GitHub Desktop.
Save sany2k8/6ee5914b0b54bf3826798623501c7457 to your computer and use it in GitHub Desktop.
CREATE SEQUENCE tbl_name_id_seq;
ALTER TABLE tbl_name ALTER COLUMN id SET DEFAULT nextval('tbl_name_id_seq');
select setval('tbl_name_id_seq', (select max(id)+1 from tbl_name), false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment