How to update a still referenced primary key in db2. ask question. up vote 1 down vote favorite. db2 doesn't support "on update cascade" and still referenced primary keys aren't allowed to change. so how can i change a name of a country while it is still used by a city? when you think about foreign keys referencing them, it becomes. In the context of relational databases, a foreign key is a field this is called a cascade delete (or update). restrict. a value cannot be updated or deleted when a row exists in a referencing or child table that references the value in the referenced table.. P_id in pk table is the primary key and p_id in fk table is the foreign key. i need to add 10 to all records in p_id column of both pk and fk table( meaning they need to match always) i know in ms sql we can easily update cascade as follows: alter table fk add constraint fk_p_id foreign key (p_id) references pk (p_id) on update cascade.
A) make your foreign key deferrable. b) set your foreign key to deferred. c) update your parent table. d) update your child table. e) set your foreign key to immediate (just to check whether you did c/d right) f) commit hth. What is a foreign key with cascade delete in sql server? a foreign key with cascade delete means that if a record in the parent table is deleted, then the corresponding records in the child table will automatically be deleted.. I design the database tables, such that the primary key is a number field that keep incrementing, like a sequence number. then i make a unique index on the table column values, and cluster on that index..
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.