当前位置:网站首页>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
边栏推荐
- MySQL索引与事务
- 还在用 Xshell?你 out 了,推荐一个更现代的终端连接工具,好用到爆!
- C# string与stream的相互转换
- Still using Xshell?You are out, recommend a more modern terminal connection tool, easy to use!
- J9数字论:DAO治理更像一种生态过程:治理原生于网络,不断演变
- Update chromedriver driver programming skills │ selenium
- 嵌入式软件打log的一些心得
- Dual machine thermal for comprehensive experiment (VRRP + OSPF + + NAT + DHCP + VTP PVSTP + single-arm routing)
- Ambari迁移Spark2到其它机器(图文教程)
- 两日总结十
猜你喜欢

【21天学习挑战赛】折半插入排序

构建资源的弹性伸缩

两日总结十

二维数组实战项目--------《扫雷游戏》
![[21 Days Learning Challenge] Half Insertion Sort](/img/30/4971479a2fa08592e88f032bb23844.png)
[21 Days Learning Challenge] Half Insertion Sort

R language multiple linear regression, ARIMA analysis of the impact of different candidates in the United States on the economic GDP time series

连流量染色都没有,你说要搞微服务?
![[GXYCTF2019]BabySQli](/img/8a/7500c0ee275d6ef8909553f34c99cf.png)
[GXYCTF2019]BabySQli

WinForm (5) control and its members

HW-常见攻击方式和漏洞原理(2)
随机推荐
SystemVerilog: Verifying knowledge bits and pieces
[GXYCTF2019]BabySQli
Is container technology really the savior of environmental management?
络达开发---自定义BLE服务(二):功能实现
22、库存服务
容器技术真的是环境管理的救星吗?
21. Aliyun oss
Qt 中的隐式共享
Data Analysis Interview Manual "SQL"
络达开发---串口日志&日志过滤
22/8/9 Collection of Greedy Problems
进程间通信(IPC)的分类以及通信方式的发展
std::format格式化自定义类型
Web APIs BOM - A Comprehensive Case of Operating Browsers
MySQL indexes and transactions
分库分表ShardingSphere-JDBC笔记整理
16. 最接近的三数之和
How to determine the size of the version number
postgresql参数意义
16. Sum of the nearest three numbers