![](/img/trans.png)
[英]Add Value from one Row to another Row with Same Primary Key- Oracle SQL
[英]Drop one Primary key and add another in oracle
我有一個表,我需要刪除主鍵,這是一個復合鍵,並使其成為基於單個值的主鍵。 我刪除了原始的主鍵:
SQL> alter table depositor
2 drop primary key;
Table altered.
但是當我嘗試添加新的后面時,我收到一條錯誤消息。
SQL> alter table depositor
2 add primary key (account_number);
alter table depositor
*
ERROR at line 1:
ORA-02437: cannot validate (ZSMITH.SYS_C0084996) - primary key violated
PK沒有掉線嗎? 我沒有正確添加嗎?
在現有表上,如果該表中的數據確實作為主鍵(即所有值為distinct而非null),則只能創建主鍵。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.