inserting data with unique index

From: "Johnson, Shaunn" <SJohnson6(at)bcbsm(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: inserting data with unique index
Date: 2003-01-14 21:15:58
Message-ID: 73309C2FDD95D11192E60008C7B1D5BB04C744FB@snt452.corp.bcbsm.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Al Bean 2003-01-14 23:58:39 postgres on a PDA
Previous Message Ragnar Garli 2003-01-14 20:58:49 Re: pg_dump fail beacuse of oid larger than int32