开发者

update primary key in oracle

开发者 https://www.devze.com 2023-01-31 15:17 出处:网络
i 开发者_Python百科have table. which has 5 columns in that 3 of the columns makes primary key combinations.

i 开发者_Python百科have table. which has 5 columns in that 3 of the columns makes primary key combinations.

table (cola, colb, colc, cold, cole)

i want to update one of the column which is in primary key group. how to do that?

its giving primary key constraint error.


You should disable do your modification an re enable the constraints that are linked to your primary key. (Unique, non-null, etc...)

Take a look at this website


If you really need to maintain uniqueness over these three columns, then define a unique constraint on the three columns making up your current PK, and then define a new surrogate primary key column.


Just in case you have to change the referncing data too. First note contrary to MS-SQL-Server there is no foreign Key contraint with on update cascade see How to create a Foreign Key with “ON UPDATE CASCADE” on Oracle?.

Than I would insert a new row in the primary table, update the referencing table to reference the new row and finally delete the original primary row.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号