oracle違反唯一約束

2021-09-01 11:20:23 字數 1020 閱讀 3491

報錯資訊:nested exception is org.hibernate.exception.constraintviolationexception: could not execute statement

背景:修改原有的邏輯,取消掉某個欄位的唯一約束。

框架:spring-data-jpa

1,查詢所有的約束

select * from user_constraints

2,根據型別 constraint_type 過濾

type code

type description

acts on level

ccheck on a table

column

oread only on a view

object

pprimary key

object

rreferential aka foreign key

column

uunique key

column

vcheck option on a view

object

//篩選唯一約束的型別

select * from user_constraints where  constraint_type = 'u'

3,根據型別 constraint_type 和表名過濾

select * from user_constraints where table_name = '表名' and constraint_type = 'u'

4,刪除唯一約束

alter table 表名drop constraint 約束名;

約束名可從以下sql獲取

selectconstraint_namefrom user_constraints where table_name = '表名' and constraint_type = 'u'

Oracle建立序列仍然違反唯一約束的問題

建立索引 create sequence seq test 插入資料 insert into s emp id,last name values seq test.nextval,huaan 先建立序列,再插入資料,正常的情況下不會有問題,但是報錯了 然後去查了下,據說是在建表的時候已經插入了部分資...

執行oracle插入語句報錯違反唯一約束問題處理

查詢最大id select max id from new guess like article 63132 查詢最大序列 select seq new guess like article.nextval from dual 插入資料 insert into uwp recommend new g...

Oracle資料庫中違反唯一約束的處理

根據null的定義,null表示的是未知,因此兩個null比較的結果既不相等,也不不等,結果仍然是未知。根據這個定義,多個null值的存在應該不違反唯一約束。實際上oracle也是如此實現的 sql create table t id number 表已建立。sql alter table t ad...