3
我想添加約束到我的表名Account
,屬性名稱Type
。 在Type
,我要添加帳戶例如類型:Saving, Credit Card, Home Loan, Personal Loan, Fixed Deposit, Current, iSaver.
爲alter table添加約束出錯
這裏就是我的代碼:
ALTER TABLE ACCOUNT
ADD CONSTRAINT AccountCK_Type
CHECK (TYPE IN('Saving','Credit Card','Home Loan','Personal Loan','Fixed Deposit','Current','iSaver'));
的錯誤顯示:
>Error report -
>
>SQL Error: ORA-02293: cannot validate (SHT461.ACCOUNTCK_TYPE) - check constraint violated
>02293. 00000 - "cannot validate (%s.%s) - check constraint violated"
>
>*Cause: an alter table operation tried to validate a check constraint to
> populated table that had nocomplying values.
>
>*Action: Obvious
請提出一個我如何添加約束。謝謝。
從其中TYPE不是IN('Saving','Credit Card','Home Loan','Personal Loan','Fixed Deposit','Current','iSaver')的ACCOUNT中選擇*。有沒有結果? – Reisclef
I.e.表中是否存在違反您嘗試創建的約束的行? – jarlh
如果有的話,你是否希望新的約束忽略這些約束,只適用於未來的插入/更新? –