当前位置:网站首页>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进阶查询
- Jvm. Profiling tools (jconsole, jvisualvm, arthas, jprofiler, mat)
- 22. Inventory service
- Dual machine thermal for comprehensive experiment (VRRP + OSPF + + NAT + DHCP + VTP PVSTP + single-arm routing)
- dump_stack()
- vim取上个窗口号.
- 颠覆性创新招商,链动2+1是个怎么样的制度模式?
- ABP中的数据过滤器
- MSTP——多生成树(案列+配置)
- 还在用 Xshell?你 out 了,推荐一个更现代的终端连接工具,好用到爆!
猜你喜欢
J9 Digital Theory: DAO governance is more like an ecological process: governance is native to the network and continues to evolve
sed of the Three Musketeers of Shell Programming
C#-委托的详细用法
Linux install redis database
MySQL索引与事务
Distributed. Performance optimization
MySQL indexes and transactions
The statistical data analysis, interview manual"
C # - delegate detailed usage
[ASM] The relationship between the role of the bytecode operation ClassWriter COMPUTE_FRAMES and visitMaxs
随机推荐
Linux安装redis数据库
成功解决TypeError: can‘t multiply sequence by non-int of type ‘float‘
[GXYCTF2019]BabySQli
还在用 Xshell?你 out 了,推荐一个更现代的终端连接工具,好用到爆!
FPGA学习专栏-串口通信(xinlinx)
总结Qt中常用文件信息QFileInfo的获取:后缀,名称,路径,链接
sed of the Three Musketeers of Shell Programming
vim取上个窗口号.
22. Inventory service
Successfully resolved raise TypeError('Unexpected feature_names type')TypeError: Unexpected feature_names type
数据库数据采集利器FlinkCDC
络达开发---UI定义+自定义按钮事件
络达开发---串口日志&日志过滤
使用mysql语句操作数据表(table)
22/8/9 贪心问题合集
微信小程序强制更新版本
使用 BeanUtils 做属性拷贝,性能有点拉胯!
循环单词
SQL statement--get database table information, table name, column name, description comment, etc.
Linux install redis database