給表追加主鍵-----報錯ORA-02437: 無法驗證 (DENGCHAO.TEST) - 違反主鍵

來源:互聯網
上載者:User

標籤:style   http   color   ar   資料   div   sp   on   c   

由於 這次 項目 做了 資料庫 遷移(從 mysql 轉到oracle  用的是navicat) 的工具  所以導致很多主鍵都丟失了

導致資料庫很多 資料的id重複  導致系統修改一條資料的時候 出現很多值相同  鬱悶了大半天 

然後 打算在plsql中 給現有的某張表  追加主鍵

教科書形式 如下 

/*

1、建立表的同時建立主鍵約束(1)無命名create table student (  studentid int primary key not null,  studentname varchar(8),  age int);(2)有命名create table students (    studentid int ,    studentname varchar(8),    age int,    constraint yy primary key(studentid));  2、刪除表中已有的主鍵約束(1)有命名 alter table students drop constraint yy;(2)無命名可用 SELECT   *   from   user_cons_columns;尋找表中主鍵名稱得student表中的主鍵名為SYS_C002715alter table student drop constraint SYS_C002715; 3、向表中添加主鍵約束 alter table student add constraint pk_student primary key(studentid);  

*/

實際項目用如下:

alter table SDINTCALENDAR
  add constraint SDINTCALENDAR_PRIMARYKEY primary key (ID)
  using index
  tablespace DEV2_DATA
  pctfree 10
  initrans 2
  maxtrans 255
  storage
  (
    initial 64K
    next 1M
    minextents 1
    maxextents unlimited
  );
 

結果報錯 ORA-02437: 無法驗證 (DENGCHAO.TEST) - 違反主鍵

查了網上 一資料 http://www.itpub.net/thread-917613-1-1.html 才恍然大悟

追加主鍵之前  必須 先刪除或修改原有重複id 的記錄 就可以了

 

給表追加主鍵-----報錯ORA-02437: 無法驗證 (DENGCHAO.TEST) - 違反主鍵

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.