inserting data with unique index - Mailing list pgsql-general

From Johnson, Shaunn
Subject inserting data with unique index
Date
Msg-id 73309C2FDD95D11192E60008C7B1D5BB04C744FB@snt452.corp.bcbsm.com
Whole thread Raw
Responses Re: inserting data with unique index
List pgsql-general

Running PostgreSQL 7.2.1 on RedHat Linux 7.2.

I have a small table where I wanted to make changes,
update the columns and insert new data.  Because it
was small, I just did a:

pg_dump -t table -U joe_user -d database > out.sql

and edit the out.sql file to add two more columns and
put 'null' in the areas where data matching to the column
would go.

That seemed to work well.

However, when I want to insert a new record into the
table, I get this:

[snip error]

ERROR:  Cannot insert a duplicate key into unique index trend_load_id_key

[/snip error]

Initially, I thought that I had to drop and create my sequence
id for the column 'load_id' ; then I tried it after I recreated
the table.  Neither worked.

[snip table info]

bcn=> \z trend
       Access privileges for database "bcn"
           Table            |  Access privileges
----------------------------+----------------------
        trend             | {=rw,shaunn=arwdRxt}
        trend_load_id_seq |
(2 rows)

  Column  |           Type           |                           Modifiers
----------+--------------------------+----------------------------------------------------------------
 load_id  | integer                  | not null default nextval('"trend_load_id_seq"'::text)
 sum_2000 | numeric(12,2)            |
 cnt_2000 | double precision         |
 sum_2001 | numeric(12,2)            |
 cnt_2001 | double precision         |
 sum_2002 | numeric(12,2)            |
 cnt_2002 | double precision         |
 sum_2003 | numeric(12,2)            |
 cnt_2003 | double precision         |
 count_dt | timestamp with time zone |
Unique keys: trend_load_id_key

[/snip table info]

How does this work?  Do I have to specify an increment starting point
when I reload data or recreate the sequence id?

Thanks!

-X

pgsql-general by date:

Previous
From: "Ragnar Garli"
Date:
Subject: Re: pg_dump fail beacuse of oid larger than int32
Next
From: "Al Bean"
Date:
Subject: postgres on a PDA