0

I don't know how to reset postgresql primary key to 1.

select pg_get_serial_sequence('table_name', 'primary_key_column') returns empty string so there is no sequence associated with this pk.

Bartosz Siemasz
  • 296
  • 1
  • 10
  • 2
    What is the type of the primary key column. Connect to your database via psql, then `\d table_name` to see which sequence is used for the column in the `Modifiers` part. – Eric Jun 16 '16 at 19:04
  • In Modifiers I got "not null" and nothing more. – Bartosz Siemasz Jul 06 '16 at 10:52
  • Then the column don't have a sequence associated. When create table, you could use `bigserial` for the id column, instead of `bigint`. – Eric Jul 06 '16 at 18:15
  • Ok, but am I able to reset the counter? – Bartosz Siemasz Jul 12 '16 at 23:03
  • If you want to to cast the int to serial, refer to: http://stackoverflow.com/questions/23578427/changing-primary-key-int-type-to-serial or http://stackoverflow.com/questions/27307835/how-to-convert-primary-key-from-integer-to-serial , and learn to search first, it's very easy to find the answers. – Eric Jul 13 '16 at 04:39

0 Answers0