Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "
2017-08-11 14:54
861 查看
插入数据postgre 报错如下
表中 vehicle__appkey id字段如下
不难看出以上错误是由于 vehicle__appkey中id字段重复导致的,而id字段的值来自于
vehicle__appKey_pkey 序列表,
START 711 标示下一个id值为712,而712的id
vehicle__appkey表中已经存在了,所以插入数据时报以上这个错误
解决方法:将"vehicle__appKey_id_seq"中的当前值设为为vehicle__appkey id的最大值
01 | ### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "vehicle__appKey_pkey" |
02 | ### The error may involve com.sq.platform.basePlatform.dao.VehicleMapper.insertVehicleAppkey-Inline |
03 | ### The error occurred while setting parameters |
04 | ### SQL: insert into vehicle__appkey(vehicle_id_fk, appkey_id_fk) values (?, ?) |
05 | ### Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "vehicle__appKey_pkey" |
06 | ; SQL []; ERROR: duplicate key value violates unique constraint "vehicle__appKey_pkey" ; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "vehicle__appKey_pkey" |
07 | at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java: 239 ) |
08 | at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java: 73 ) |
09 | at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java: 74 ) |
10 | at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java: 399 ) |
11 | at com.sun.proxy.$Proxy11.insert(Unknown Source) |
1 | id integer NOT NULL DEFAULT nextval('"vehicle__appKey_id_seq"'::regclass), |
1 |
1 |
1 | vehicle__appKey_pkey 序列表如下 |
1 | <span style= "font-family: Arial, Helvetica, sans-serif;" >-- Sequence: "vehicle__appKey_id_seq" </span> |
01 | <pre name= "code" class = "java" > |
02 | -- DROP SEQUENCE "vehicle__appKey_id_seq" ; |
03 |
04 | CREATE SEQUENCE "vehicle__appKey_id_seq" |
05 | INCREMENT 1 |
06 | MINVALUE 1 |
07 | MAXVALUE 9223372036854775807 |
08 | <span style= "color:#ff0000;" >START 711 </span> |
09 | CACHE 1 ; |
10 | ALTER TABLE "vehicle__appKey_id_seq" |
11 | OWNER TO postgres; |
vehicle__appKey_pkey 序列表,
START 711 标示下一个id值为712,而712的id
vehicle__appkey表中已经存在了,所以插入数据时报以上这个错误
解决方法:将"vehicle__appKey_id_seq"中的当前值设为为vehicle__appkey id的最大值
相关文章推荐
- Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "veh
- ERROR: duplicate key value violates unique constraint "xxx"
- IntegrityError duplicate key value violates unique constraint - django/postgres
- postgresql插入数据提示:duplicate key value violates unique constraint
- postgres 错误duplicate key value violates unique constraint 解决方案
- [JAVA][Liferay] Duplicate key value violates unique constraint for resourcepermissionid in Liferay
- Cause: org.postgresql.util.PSQLException: ERROR: cached plan must not change result type的前因后果
- org.postgresql.util.PSQLException: ERROR: column "loginid" of relation "userinfo" does not exist
- Mybatis:org.postgresql.util.PSQLException: ERROR: relation "summarytdglinfo" does not ex
- Caused by: org.postgresql.util.PSQLException: ERROR: relation "item" does not exist
- postgresql duplicate key violates unique constraint
- org.codehaus.jackson.map.JsonMappingException: Can not construct instance of java.util.Date from String value '2012-12-12 12:01:01': not a valid representation (error: Can not parse date "2012-12-
- 关于rg.postgresql.util.PSQLException: ERROR: zero-length delimited identifier at or near """"的解决办法
- how to solve Error cannot add duplicate collection entry of type add with unique key attribute 'valu
- postgreSQL异常总结一:org.postgresql.util.PSQLException: 错误: 对关系 ppol 权限不够
- ERROR: org.hibernate.util.JDBCExceptionReporter - ORA-00904: "XXXX": invalid identifie
- Defining <uniqueKey> as a "long" or "int" type throws an error on startup
- Error when sending message to topic test with key: null, value: 2 bytes with error: (org.apache.kafka.clients.producer.internals.ErrorLoggingCallback)
- java.lang.LinkageError: loader constraint violation: when resolving method "org.slf4j.impl.StaticLog
- Exception in thread "main" java.util.ServiceConfigurationError: org.apache.juli.logging.Log: Provid