By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,261 Members | 2,662 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,261 IT Pros & Developers. It's quick & easy.

Update tables with primary key

P: n/a
Hi to all !!!
I am new working with DB2.

I have one table with 4 primary key (CLIENTID,
TIMESTAMP,ENTITYTYPE,ENTITYID)
and I need update this table (HISTORY).

First I drop the Primary Key, after make update the table (HISTORY) and
of last create ADD the Primary Key (PK_CLIHISTORY), but show this
message

A primary or unique key index cannot be created because the table
contains rows which are duplicates with respect to the values of the
identified primary or unique key columns of constraint "PK_CLIHISTORY".

If somebody knows how I can make this update. I am thankful to him
helps me.

Greetings!!!

Iván

Aug 24 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Ivan wrote:
First I drop the Primary Key, after make update the table (HISTORY) and
of last create ADD the Primary Key (PK_CLIHISTORY), but show this
message
[...]

Hm... This means that the column PK_CLIHISTORY contains duplicate values
which is not an option for primary keys.

So you have to make your primary keys unique. If you can't do this, you
may put more columns into the primary key.

ALTER TABLE "table" ADD PRIMARY KEY ("PK_CLHISTORY","PK_CLIENTID"); (or
whatever) and set an index on PK_CLHISTORY (which isn't a real primary
key now).

Bernd

Aug 24 '06 #2

P: n/a
Ivan,

not sure why you would want to drop your primary key before doing your
update? If you leave it there, the update that causes the unique
violation will fail and you can quickly identify the offending values.
If you're sure that the updates are what they should be, then you can't
have a primary key made up only of the columns you use now.

/T

Ivan wrote:
Hi to all !!!
I am new working with DB2.

I have one table with 4 primary key (CLIENTID,
TIMESTAMP,ENTITYTYPE,ENTITYID)
and I need update this table (HISTORY).

First I drop the Primary Key, after make update the table (HISTORY) and
of last create ADD the Primary Key (PK_CLIHISTORY), but show this
message

A primary or unique key index cannot be created because the table
contains rows which are duplicates with respect to the values of the
identified primary or unique key columns of constraint "PK_CLIHISTORY".

If somebody knows how I can make this update. I am thankful to him
helps me.

Greetings!!!

Iván
Aug 25 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.