2

Before you mark this a duplicate. I found this answer on another thread and having difficulties making it work.

From psql I see my table:

\d people

Table:

Column       |                   Type                |                        Modifiers
---------------+----------------------------------+-----------------------------------------------------------------------
id                 |               integer                 |       not null default nextval('people_id_seq'::regclass)

Code I tried which seems to do nothing...

ALTER SEQUENCE people_id_seq RESTART 1000

How do I make the primary key start from 1000?

MrPizzaFace
  • 7,807
  • 15
  • 79
  • 123

2 Answers2

7

The following query would set the sequence value to 999. The next time the sequence is accessed, you would get 1000.

SELECT setval('people_id_seq', 999);

Reference:

Sequence Manipulation Functions on PostgreSQL Manual

Joseph B
  • 5,519
  • 1
  • 15
  • 19
2

Why are you declaring your id like that ?

I mean, I would do the following :

create table people( id serial, constraint primaryKeyID primary key(id));

And now if you want to start your sequence from 1000, your alter query will work.

alter sequence people_id_seq restart 1000

user3448717
  • 73
  • 1
  • 6