当前位置:网站首页>ora-00001违反唯一约束
ora-00001违反唯一约束
2022-08-11 01:26:00 【森林迷了~鹿】
ora-00001违反唯一约束
报错日志:
org.springframework.dao.DuplicateKeyException:
### Error updating database. Cause: java.sql.SQLIntegrityConstraintViolationException: ORA-00001: 违反唯一约束条件 (RPA_USER.PK_ACCEPTED_WITNESSVIDEO)
### The error may exist in com/bairuitech/anychat/iaccount/dao/TAcceptedWitnessvideoMapper.java (best guess)
### The error may involve com.bairuitech.anychat.iaccount.dao.TAcceptedWitnessvideoMapper.insert-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO T_ACCEPTED_WITNESSVIDEO ( ID, SRV_STREAM, CUST_NAME, CUST_STREAM, SYS_PATH, SRV_ID, CUST_ID, SRV_NAME ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ? )
### Cause: java.sql.SQLIntegrityConstraintViolationException: ORA-00001: 违反唯一约束条件 (RPA_USER.PK_ACCEPTED_WITNESSVIDEO)
; ORA-00001: 违反唯一约束条件 (RPA_USER.PK_ACCEPTED_WITNESSVIDEO)
; nested exception is java.sql.SQLIntegrityConstraintViolationException: ORA-00001: 违反唯一约束条件 (RPA_USER.PK_ACCEPTED_WITNESSVIDEO)
原因:
在表中要求唯一的值发生了冲突,比如现在id的值已经增长到了100,序列的下一个值是24,Oracle执行插入时,生成的id是24已经存在了
解决方法:
修改该表的下一个序列值大于当前最大的唯一值
步骤:
1.可以先看是哪张表哪个字段发生的冲突(一般是主键id):
select a.constraint_name,a.constraint_type,b.column_name,b.table_name from user_constraints a inner join user_cons_columns b on a.table_name=b.table_name where a.constraint_name='PK_ACCEPTED_WITNESSVIDEO'
2.查询Oracle数据库所有序列:
select * from USER_SEQUENCES;
3.查询指定数据库表序列id参数值(倒序)
select max(to_number(t.表id)) from 表名(所报异常查询表)t
4.查询当前表值的下一个序列值(对比上一步的查询结果)
SELECT 序列名.NEXTVAL FROM dual; ---执行后,序列会自增
5.修改序列的值的增长值:
alter sequence 序列名 increment BY X; ----X为正数负数都可以
6.查询序列的下一个值:
SELECT 序列名.NEXTVAL FROM dual; --查看是否已经大于id的最大值
7.重新将序列的值的增长值设为1
alter sequence 序列名 increment BY 1; ---序列自增设为1
边栏推荐
- C# string与stream的相互转换
- 16. 最接近的三数之和
- loop word
- How to determine the size of the version number
- Dual machine thermal for comprehensive experiment (VRRP + OSPF + + NAT + DHCP + VTP PVSTP + single-arm routing)
- 版本号大小的判断方法
- 21、阿里云oss
- Shell 文本三剑客 Sed
- Mysql database installation and configuration detailed tutorial
- Shell Text Three Musketeers Sed
猜你喜欢

Apache Commons Configuration Remote Code Execution Vulnerability (CVE-2022-33980) Analysis & Reproduction

wincc如何实现远程监控1200PLC

使用mysql语句操作数据表(table)

22. Inventory service

颠覆性创新招商,链动2+1是个怎么样的制度模式?

Still using Xshell?You are out, recommend a more modern terminal connection tool, easy to use!

MySQL indexes and transactions

Word set before the title page

微服务概念

Mysql数据库安装配置详细教程
随机推荐
Word set before the title page
16. Sum of the nearest three numbers
zerorpc:async=True can be written as **{“async“: True}
[21 Days Learning Challenge] Half Insertion Sort
深度解析:什么是太爱速M抢单模式?
颠覆性创新招商,链动2+1是个怎么样的制度模式?
编程技巧│selenium 更新 chromedriver 驱动
vim取上个窗口号.
数据分析面试手册《SQL篇》
两日总结十一
C# using timer
络达开发---UI定义+自定义按钮事件
paddle2.3和torch1.8在SentenceBert上的性能对比
postgresql参数意义
word 设置标题前分页
如何防止离职员工把企业文件拷贝带走?法律+技术,4步走
【21天学习挑战赛】折半插入排序
构建资源的弹性伸缩
More parameter exposure of Pico 4: Pancake + color perspective, and Pro version
Exception: try catch finally throws throw