Sql updating primary key value
If a table already exists, you can add PRIMARY KEY constraint, provided that no other PRIMARY KEY constraint already exists. If a PRIMARY KEY constraint already exists, you can modify or delete it.For example, you may want the PRIMARY KEY constraint of the table to reference other columns, or you may want to change the column order, index name, clustered option, or fill factor of the PRIMARY KEY constraint.Alternatively, you can use deferred constraints as well.If you create the foreign keys "deferrable", you can set constraints deferred; update parent_table; update child_table(s); commit; and the constraint will be verified at the commit instead of at the statement level, allowing you to "cascade" the update yourself.Thanks, update drt555 set procnum,='888' 2* where procnum='777' and lcncod='PHX' update drt555 set procnum='888' * ERROR at line 1: ORA-02291: integrity constraint (YD.FK_DRT555_PROCNUM_LCNCOD) violated - parent key not found Elapsed: .02 [email protected] Most people do not -- it fails the commit and I'll betcha most applications would not deal with that nicely -- they are not expecting a commit to fail.By commenting, you are accepting the IBM commenting guidelines and the DISQUS terms of service.
INITIALLY IMMEDIATE Specify INITIALLY IMMEDIATE to indicate that at the start of every transaction, the default is to check this constraint at the end of every DML statement.Thanks for being a member of the Ask TOM community. This year we've answered over 2800 of your questions and followed up on 3500 reviews. Dear tom, please let me know how can i update a record in the primary key field which behaves as a foreign key to other tables without altering (disabling) the primary/foreign constraint????please reply sooon yours faithfully, SACHIN JAIN for one solution.Updating the primary key in a database is not normally necessary.Some RDBMSs do not support updating the primary key.