Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2002

    Question Doubt in Primary Key

    I am using DB2/400 in AS400. I am told as a rule fields which are defined as primary key within a table should not be modifiable. That is if you issue an update statement in which one of the fields which is part of primary key is also getting modified, system should give an error. But when I did this in DB2/400, it went through succesfully.

    I would like to mention that ther is no RI with regard to this table.

    1) Is it only a principle that primary key should not be changed?
    2) If yes how there is no error message?

    Please help
    Last edited by muthuprakash99; 04-10-03 at 10:42.

  2. #2
    Join Date
    Apr 2002
    Toronto, Canada
    you are opening a very large can of worms

    the problem with modifying the value of a primary key is that very few databases support the ON UPDATE CASCADE concept

    if they did, then perhaps changing a primary key value would not be much of an issue

    here's an experiment

    create two tables, with a foreign key relationship from one table (the child) to the other (the parent)

    populate some rows, and make sure the child rows are properly related to their parent rows

    now update a primary key value in the parent to some new value, and see if it actually performs the update, or issues an error message, or performs the update on the foreign key value(s) as well...


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts