pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Duplicate Unique Key constraint error
10+ messages / 6 participants
[nested] [flat]

* Duplicate Unique Key constraint error
@ 2007-07-10 05:14 Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
  2007-07-10 06:01 ` Re: Duplicate Unique Key constraint error Ron St-Pierre <ron.pgsql@shaw.ca>
  0 siblings, 1 reply; 10+ messages in thread

From: Harpreet Dhaliwal @ 2007-07-10 05:14 UTC (permalink / raw)
  To: Postgres General <pgsql-general@postgresql.org>

Hi,

I keep getting this duplicate unique key constraint error for my primary key
even
though I'm not inserting anything duplicate. It even inserts the records
properly
but my console throws this error that I'm sure of what it is all about.

Corruption of my Primary Key can be one of the possibilities but I'm really
not sure how
to get rid of this corruption and how to re-index the primary key.

Also, I was wondering what could be the cause of this PK  corruption, if
possible and what does can this corruption lead to.
I mean what are its cons.

Thanks,
~Harpreet

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Duplicate Unique Key constraint error
  2007-07-10 05:14 Duplicate Unique Key constraint error Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
@ 2007-07-10 06:01 ` Ron St-Pierre <ron.pgsql@shaw.ca>
  2007-07-10 17:57   ` Re: Duplicate Unique Key constraint error Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
  0 siblings, 1 reply; 10+ messages in thread

From: Ron St-Pierre @ 2007-07-10 06:01 UTC (permalink / raw)
  To: Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>; +Cc: Postgres General <pgsql-general@postgresql.org>

Harpreet Dhaliwal wrote:
> Hi,
>
> I keep getting this duplicate unique key constraint error for my 
> primary key even
> though I'm not inserting anything duplicate. It even inserts the 
> records properly
> but my console throws this error that I'm sure of what it is all about.
>
> Corruption of my Primary Key can be one of the possibilities but I'm 
> really not sure how
> to get rid of this corruption and how to re-index the primary key.
>
> Also, I was wondering what could be the cause of this PK  corruption, 
> if possible and what does can this corruption lead to.
> I mean what are its cons.
>
> Thanks,
> ~Harpreet
You haven't really given any useful information about your primary key, 
but if you are using SERIAL as the column type (INT type with a 
sequence) you may just be having a problem with its current value (but 
then inserts shouldn't work).

If you are using a sequence here, see what it's current value is and 
compare it to the highest value in the column. If its value is less than 
the columns max() value, just reset the value in the sequence.

imp=# CREATE TABLE dup_pkey (id SERIAL PRIMARY KEY, insert_order int);
imp=# INSERT INTO dup_pkey (insert_order) VALUES (1);
imp=# INSERT INTO dup_pkey (insert_order) VALUES (2);
imp=# INSERT INTO dup_pkey (insert_order) VALUES (3);
imp=# INSERT INTO dup_pkey (insert_order) VALUES (4);

imp=# SELECT * FROM dup_pkey;
 id | insert_order
----+--------------
  1 |            1
  2 |            2
  3 |            3
  4 |            4
(4 rows)

Now, if you set the value below what the max() column value is, you will 
have a problem with inserts.
imp=# SELECT setval('dup_pkey_id_seq',3);
 setval
--------
      3
(1 row)

imp=# INSERT INTO dup_pkey (insert_order) VALUES (5);
ERROR:  duplicate key violates unique constraint "dup_pkey_pkey"


If this is the case, use setval() to update the value of the sequence to 
the max() value of your primary key. You can use \d to get information 
about your table, including the sequence name. However if, as you say, 
it IS inserting records properly, then this ISN'T going to help.

hth

Ron



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Duplicate Unique Key constraint error
  2007-07-10 05:14 Duplicate Unique Key constraint error Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
  2007-07-10 06:01 ` Re: Duplicate Unique Key constraint error Ron St-Pierre <ron.pgsql@shaw.ca>
@ 2007-07-10 17:57   ` Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
  2007-07-10 18:22     ` Re: Duplicate Unique Key constraint error Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
  0 siblings, 1 reply; 10+ messages in thread

From: Harpreet Dhaliwal @ 2007-07-10 17:57 UTC (permalink / raw)
  To: Ron St-Pierre <ron.pgsql@shaw.ca>; +Cc: Postgres General <pgsql-general@postgresql.org>

my primary key is neither SERIAL nor a SEQUENCE.

CONSTRAINT pk_dig PRIMARY KEY (dig_id)

This is the clause that I have for my primary key in the create table
script.

thanks,
~Harpreet

On 7/10/07, Ron St-Pierre <ron.pgsql@shaw.ca> wrote:
>
> Harpreet Dhaliwal wrote:
> > Hi,
> >
> > I keep getting this duplicate unique key constraint error for my
> > primary key even
> > though I'm not inserting anything duplicate. It even inserts the
> > records properly
> > but my console throws this error that I'm sure of what it is all about.
> >
> > Corruption of my Primary Key can be one of the possibilities but I'm
> > really not sure how
> > to get rid of this corruption and how to re-index the primary key.
> >
> > Also, I was wondering what could be the cause of this PK  corruption,
> > if possible and what does can this corruption lead to.
> > I mean what are its cons.
> >
> > Thanks,
> > ~Harpreet
> You haven't really given any useful information about your primary key,
> but if you are using SERIAL as the column type (INT type with a
> sequence) you may just be having a problem with its current value (but
> then inserts shouldn't work).
>
> If you are using a sequence here, see what it's current value is and
> compare it to the highest value in the column. If its value is less than
> the columns max() value, just reset the value in the sequence.
>
> imp=# CREATE TABLE dup_pkey (id SERIAL PRIMARY KEY, insert_order int);
> imp=# INSERT INTO dup_pkey (insert_order) VALUES (1);
> imp=# INSERT INTO dup_pkey (insert_order) VALUES (2);
> imp=# INSERT INTO dup_pkey (insert_order) VALUES (3);
> imp=# INSERT INTO dup_pkey (insert_order) VALUES (4);
>
> imp=# SELECT * FROM dup_pkey;
> id | insert_order
> ----+--------------
>   1 |            1
>   2 |            2
>   3 |            3
>   4 |            4
> (4 rows)
>
> Now, if you set the value below what the max() column value is, you will
> have a problem with inserts.
> imp=# SELECT setval('dup_pkey_id_seq',3);
> setval
> --------
>       3
> (1 row)
>
> imp=# INSERT INTO dup_pkey (insert_order) VALUES (5);
> ERROR:  duplicate key violates unique constraint "dup_pkey_pkey"
>
>
> If this is the case, use setval() to update the value of the sequence to
> the max() value of your primary key. You can use \d to get information
> about your table, including the sequence name. However if, as you say,
> it IS inserting records properly, then this ISN'T going to help.
>
> hth
>
> Ron
>

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Duplicate Unique Key constraint error
  2007-07-10 05:14 Duplicate Unique Key constraint error Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
  2007-07-10 06:01 ` Re: Duplicate Unique Key constraint error Ron St-Pierre <ron.pgsql@shaw.ca>
  2007-07-10 17:57   ` Re: Duplicate Unique Key constraint error Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
@ 2007-07-10 18:22     ` Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
  2007-07-10 18:35       ` Re: Duplicate Unique Key constraint error Michael Glaesemann <grzm@seespotcode.net>
  2007-07-10 19:09       ` Re: Duplicate Unique Key constraint error Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 10+ messages in thread

From: Harpreet Dhaliwal @ 2007-07-10 18:22 UTC (permalink / raw)
  To: Ron St-Pierre <ron.pgsql@shaw.ca>; +Cc: Postgres General <pgsql-general@postgresql.org>

I lately figured out the actual problem PHEW.
Its something like two different transactions are seeing the same snapshot
of the database.

Transaction 1 started, saw max(dig_id) = 30 and inserted new dig_id=31.
Now the time when Transaction 2 started and read max(dig_id) it was still 30
and by the time it tried to insert 31, 31 was already inserted by
Transaction 1 and hence the unique key constraint error.

I thought this would be taken care by the database itself by locking the
transactions but now I really don't know how does this locking takes place
in postgres. I used to work with SQL Server and never faced this problem
there.

Please guide me throug to get rid of this problem.

Thanks,
~Harpreet

On 7/10/07, Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com> wrote:
>
> my primary key is neither SERIAL nor a SEQUENCE.
>
> CONSTRAINT pk_dig PRIMARY KEY (dig_id)
>
> This is the clause that I have for my primary key in the create table
> script.
>
> thanks,
> ~Harpreet
>
> On 7/10/07, Ron St-Pierre <ron.pgsql@shaw.ca> wrote:
> >
> > Harpreet Dhaliwal wrote:
> > > Hi,
> > >
> > > I keep getting this duplicate unique key constraint error for my
> > > primary key even
> > > though I'm not inserting anything duplicate. It even inserts the
> > > records properly
> > > but my console throws this error that I'm sure of what it is all
> > about.
> > >
> > > Corruption of my Primary Key can be one of the possibilities but I'm
> > > really not sure how
> > > to get rid of this corruption and how to re-index the primary key.
> > >
> > > Also, I was wondering what could be the cause of this PK  corruption,
> > > if possible and what does can this corruption lead to.
> > > I mean what are its cons.
> > >
> > > Thanks,
> > > ~Harpreet
> > You haven't really given any useful information about your primary key,
> > but if you are using SERIAL as the column type (INT type with a
> > sequence) you may just be having a problem with its current value (but
> > then inserts shouldn't work).
> >
> > If you are using a sequence here, see what it's current value is and
> > compare it to the highest value in the column. If its value is less than
> >
> > the columns max() value, just reset the value in the sequence.
> >
> > imp=# CREATE TABLE dup_pkey (id SERIAL PRIMARY KEY, insert_order int);
> > imp=# INSERT INTO dup_pkey (insert_order) VALUES (1);
> > imp=# INSERT INTO dup_pkey (insert_order) VALUES (2);
> > imp=# INSERT INTO dup_pkey (insert_order) VALUES (3);
> > imp=# INSERT INTO dup_pkey (insert_order) VALUES (4);
> >
> > imp=# SELECT * FROM dup_pkey;
> > id | insert_order
> > ----+--------------
> >   1 |            1
> >   2 |            2
> >   3 |            3
> >   4 |            4
> > (4 rows)
> >
> > Now, if you set the value below what the max() column value is, you will
> > have a problem with inserts.
> > imp=# SELECT setval('dup_pkey_id_seq',3);
> > setval
> > --------
> >       3
> > (1 row)
> >
> > imp=# INSERT INTO dup_pkey (insert_order) VALUES (5);
> > ERROR:  duplicate key violates unique constraint "dup_pkey_pkey"
> >
> >
> > If this is the case, use setval() to update the value of the sequence to
> >
> > the max() value of your primary key. You can use \d to get information
> > about your table, including the sequence name. However if, as you say,
> > it IS inserting records properly, then this ISN'T going to help.
> >
> > hth
> >
> > Ron
> >
>
>

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Duplicate Unique Key constraint error
  2007-07-10 05:14 Duplicate Unique Key constraint error Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
  2007-07-10 06:01 ` Re: Duplicate Unique Key constraint error Ron St-Pierre <ron.pgsql@shaw.ca>
  2007-07-10 17:57   ` Re: Duplicate Unique Key constraint error Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
  2007-07-10 18:22     ` Re: Duplicate Unique Key constraint error Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
@ 2007-07-10 18:35       ` Michael Glaesemann <grzm@seespotcode.net>
  1 sibling, 0 replies; 10+ messages in thread

From: Michael Glaesemann @ 2007-07-10 18:35 UTC (permalink / raw)
  To: Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>; +Cc: Ron St-Pierre <ron.pgsql@shaw.ca>; Postgres General <pgsql-general@postgresql.org>


On Jul 10, 2007, at 13:22 , Harpreet Dhaliwal wrote:

> Transaction 1 started, saw max(dig_id) = 30 and inserted new  
> dig_id=31.
> Now the time when Transaction 2 started and read max(dig_id) it was  
> still 30
> and by the time it tried to insert 31, 31 was already inserted by
> Transaction 1 and hence the unique key constraint error.
>
> I thought this would be taken care by the database itself by  
> locking the
> transactions but now I really don't know how does this locking  
> takes place
> in postgres.

Why would the server lock the table? It can't know your intention is  
to add one to the number returned and insert. If this is what you  
want, you have to lock the table explicitly.

> Please guide me throug to get rid of this problem.

This exact reason is why sequences are often used for primary keys. I  
recommend you change your primary key.


Michael Glaesemann
grzm seespotcode net





^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Duplicate Unique Key constraint error
  2007-07-10 05:14 Duplicate Unique Key constraint error Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
  2007-07-10 06:01 ` Re: Duplicate Unique Key constraint error Ron St-Pierre <ron.pgsql@shaw.ca>
  2007-07-10 17:57   ` Re: Duplicate Unique Key constraint error Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
  2007-07-10 18:22     ` Re: Duplicate Unique Key constraint error Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
@ 2007-07-10 19:09       ` Tom Lane <tgl@sss.pgh.pa.us>
  2007-07-10 19:33         ` Re: Duplicate Unique Key constraint error Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
  2007-07-11 10:24         ` Re: Duplicate Unique Key constraint error Tom Allison <tom@tacocat.net>
  1 sibling, 2 replies; 10+ messages in thread

From: Tom Lane @ 2007-07-10 19:09 UTC (permalink / raw)
  To: Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>; +Cc: Ron St-Pierre <ron.pgsql@shaw.ca>; Postgres General <pgsql-general@postgresql.org>

"Harpreet Dhaliwal" <harpreet.dhaliwal01@gmail.com> writes:
> Transaction 1 started, saw max(dig_id) = 30 and inserted new dig_id=31.
> Now the time when Transaction 2 started and read max(dig_id) it was still 30
> and by the time it tried to insert 31, 31 was already inserted by
> Transaction 1 and hence the unique key constraint error.

This is exactly why you're recommended to use sequences (ie serial
columns) for generating IDs.  Taking max()+1 does not work, unless
you're willing to lock the whole table and throw away vast amounts of
concurrency.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Duplicate Unique Key constraint error
  2007-07-10 05:14 Duplicate Unique Key constraint error Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
  2007-07-10 06:01 ` Re: Duplicate Unique Key constraint error Ron St-Pierre <ron.pgsql@shaw.ca>
  2007-07-10 17:57   ` Re: Duplicate Unique Key constraint error Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
  2007-07-10 18:22     ` Re: Duplicate Unique Key constraint error Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
  2007-07-10 19:09       ` Re: Duplicate Unique Key constraint error Tom Lane <tgl@sss.pgh.pa.us>
@ 2007-07-10 19:33         ` Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
  1 sibling, 0 replies; 10+ messages in thread

From: Harpreet Dhaliwal @ 2007-07-10 19:33 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Ron St-Pierre <ron.pgsql@shaw.ca>; Postgres General <pgsql-general@postgresql.org>

Thanks alot for all your suggestions gentlemen.
I changed it to a SERIAL column and all the pain has been automatically
alleviated :)

Thanks a ton.
~Harpreet

On 7/10/07, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> "Harpreet Dhaliwal" <harpreet.dhaliwal01@gmail.com> writes:
> > Transaction 1 started, saw max(dig_id) = 30 and inserted new dig_id=31.
> > Now the time when Transaction 2 started and read max(dig_id) it was
> still 30
> > and by the time it tried to insert 31, 31 was already inserted by
> > Transaction 1 and hence the unique key constraint error.
>
> This is exactly why you're recommended to use sequences (ie serial
> columns) for generating IDs.  Taking max()+1 does not work, unless
> you're willing to lock the whole table and throw away vast amounts of
> concurrency.
>
>                         regards, tom lane
>

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Duplicate Unique Key constraint error
  2007-07-10 05:14 Duplicate Unique Key constraint error Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
  2007-07-10 06:01 ` Re: Duplicate Unique Key constraint error Ron St-Pierre <ron.pgsql@shaw.ca>
  2007-07-10 17:57   ` Re: Duplicate Unique Key constraint error Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
  2007-07-10 18:22     ` Re: Duplicate Unique Key constraint error Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
  2007-07-10 19:09       ` Re: Duplicate Unique Key constraint error Tom Lane <tgl@sss.pgh.pa.us>
@ 2007-07-11 10:24         ` Tom Allison <tom@tacocat.net>
  2007-07-13 00:21           ` Re: Duplicate Unique Key constraint error Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
  1 sibling, 1 reply; 10+ messages in thread

From: Tom Allison @ 2007-07-11 10:24 UTC (permalink / raw)
  To: Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>; +Cc: Postgres General <pgsql-general@postgresql.org>


On Jul 10, 2007, at 3:09 PM, Tom Lane wrote:

>
> "Harpreet Dhaliwal" <harpreet.dhaliwal01@gmail.com> writes:
>> Transaction 1 started, saw max(dig_id) = 30 and inserted new  
>> dig_id=31.
>> Now the time when Transaction 2 started and read max(dig_id) it  
>> was still 30
>> and by the time it tried to insert 31, 31 was already inserted by
>> Transaction 1 and hence the unique key constraint error.
>
> This is exactly why you're recommended to use sequences (ie serial
> columns) for generating IDs.  Taking max()+1 does not work, unless
> you're willing to lock the whole table and throw away vast amounts of
> concurrency.

I wonder how SQL server is handling this?  Are they locking the table?
I realize it's off-topic, but I'm still curious.

Sequences are your friend.  they come in INT and BIGINT flavors, but  
BIGINT is a lot of rows.

Can set set Sequences to automatically rollover back to zero?




^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Duplicate Unique Key constraint error
  2007-07-10 05:14 Duplicate Unique Key constraint error Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
  2007-07-10 06:01 ` Re: Duplicate Unique Key constraint error Ron St-Pierre <ron.pgsql@shaw.ca>
  2007-07-10 17:57   ` Re: Duplicate Unique Key constraint error Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
  2007-07-10 18:22     ` Re: Duplicate Unique Key constraint error Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
  2007-07-10 19:09       ` Re: Duplicate Unique Key constraint error Tom Lane <tgl@sss.pgh.pa.us>
  2007-07-11 10:24         ` Re: Duplicate Unique Key constraint error Tom Allison <tom@tacocat.net>
@ 2007-07-13 00:21           ` Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
  2007-07-13 00:58             ` Re: Duplicate Unique Key constraint error Alvaro Herrera <alvherre@commandprompt.com>
  0 siblings, 1 reply; 10+ messages in thread

From: Harpreet Dhaliwal @ 2007-07-13 00:21 UTC (permalink / raw)
  To: Tom Allison <tom@tacocat.net>; +Cc: Postgres General <pgsql-general@postgresql.org>

How can one rollover a sequence back to zero after you delete records from a
table with one such sequence.
I see it starting with the last value of the sequence inserted.


On 7/11/07, Tom Allison <tom@tacocat.net> wrote:
>
>
> On Jul 10, 2007, at 3:09 PM, Tom Lane wrote:
>
> >
> > "Harpreet Dhaliwal" <harpreet.dhaliwal01@gmail.com> writes:
> >> Transaction 1 started, saw max(dig_id) = 30 and inserted new
> >> dig_id=31.
> >> Now the time when Transaction 2 started and read max(dig_id) it
> >> was still 30
> >> and by the time it tried to insert 31, 31 was already inserted by
> >> Transaction 1 and hence the unique key constraint error.
> >
> > This is exactly why you're recommended to use sequences (ie serial
> > columns) for generating IDs.  Taking max()+1 does not work, unless
> > you're willing to lock the whole table and throw away vast amounts of
> > concurrency.
>
> I wonder how SQL server is handling this?  Are they locking the table?
> I realize it's off-topic, but I'm still curious.
>
> Sequences are your friend.  they come in INT and BIGINT flavors, but
> BIGINT is a lot of rows.
>
> Can set set Sequences to automatically rollover back to zero?
>
>

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Duplicate Unique Key constraint error
  2007-07-10 05:14 Duplicate Unique Key constraint error Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
  2007-07-10 06:01 ` Re: Duplicate Unique Key constraint error Ron St-Pierre <ron.pgsql@shaw.ca>
  2007-07-10 17:57   ` Re: Duplicate Unique Key constraint error Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
  2007-07-10 18:22     ` Re: Duplicate Unique Key constraint error Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
  2007-07-10 19:09       ` Re: Duplicate Unique Key constraint error Tom Lane <tgl@sss.pgh.pa.us>
  2007-07-11 10:24         ` Re: Duplicate Unique Key constraint error Tom Allison <tom@tacocat.net>
  2007-07-13 00:21           ` Re: Duplicate Unique Key constraint error Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
@ 2007-07-13 00:58             ` Alvaro Herrera <alvherre@commandprompt.com>
  0 siblings, 0 replies; 10+ messages in thread

From: Alvaro Herrera @ 2007-07-13 00:58 UTC (permalink / raw)
  To: Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>; +Cc: Tom Allison <tom@tacocat.net>; Postgres General <pgsql-general@postgresql.org>

Harpreet Dhaliwal escribió:
> How can one rollover a sequence back to zero after you delete records from 
> a
> table with one such sequence.
> I see it starting with the last value of the sequence inserted.

You can use setval(), but normally you just leave it alone.  Having
numbers not starting from 0 is not a problem in most cases.

-- 
Alvaro Herrera                         http://www.flickr.com/photos/alvherre/
Hi! I'm a .signature virus!
cp me into your .signature file to help me spread!



^ permalink  raw  reply  [nested|flat] 10+ messages in thread


end of thread, other threads:[~2007-07-13 00:58 UTC | newest]

Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-07-10 05:14 Duplicate Unique Key constraint error Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
2007-07-10 06:01 ` Ron St-Pierre <ron.pgsql@shaw.ca>
2007-07-10 17:57   ` Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
2007-07-10 18:22     ` Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
2007-07-10 18:35       ` Michael Glaesemann <grzm@seespotcode.net>
2007-07-10 19:09       ` Tom Lane <tgl@sss.pgh.pa.us>
2007-07-10 19:33         ` Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
2007-07-11 10:24         ` Tom Allison <tom@tacocat.net>
2007-07-13 00:21           ` Harpreet Dhaliwal <harpreet.dhaliwal01@gmail.com>
2007-07-13 00:58             ` Alvaro Herrera <alvherre@commandprompt.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox