Toggle navigation
PostgreSQL中文社区
首页
(current)
社区新闻
中文文档
加入ACE
相关资料
了解PostgreSQL
PostgreSQL相关文档
PostgreSQL软件下载
PostgreSQL中文图书
社区年会PPT资料
关于中文社区
注册
登录
全部
Bug
使用技巧
内容问题
建议
系统安装
集群复制
其他
首页
有问有答(FAQ)
【%E5%85%B6%E4%BB%96】
类主题列表
jienijieni
主键存在重复值 ...
... 2019-03-27 16:48:32+08...1楼
### 问题描述 PG版本是10.0 1. 表结构如下 ``` Table "ams.assets_device_entity" Column | Type | Collation | Nullable | Default -------------------+-----------------------------+-----------+----------+-------------------------------------------------- id | bigint | | not null | nextval('assets_device_entity_id_seq'::regclass) device_no | character varying(64) | | | product_id | bigint | | | device_version_id | integer | | | status | integer | | | position | integer | | | position_id | bigint | | | parent_box_no | character varying(64) | | | create_time | timestamp without time zone | | | update_time | timestamp without time zone | | | assets_status | integer | | | abnormal_id | bigint | | | parent_type | smallint | | | parent_id | character varying(64) | | | device_status | smallint | | | Indexes: "assets_device_entity_id_pkey" PRIMARY KEY, btree (id) "assets_device_entity_device_no" UNIQUE, btree (device_no) "idx_assets_device_entity_position_position_id" btree ("position", position_id) ``` 2. 执行select ``` dx2=# SELECT * FROM assets_device_entity where id=1124767; -[ RECORD 1 ]-----+------------------------- id | 1124767 device_no | p010000000592652 product_id | 90 device_version_id | status | 0 position | 4 position_id | 138021 parent_box_no | 868658033042785 create_time | 2018-05-28 13:44:15.281 update_time | 2019-03-17 10:40:00.649 assets_status | 0 abnormal_id | parent_type | 2 parent_id | 411903176171519561529084 device_status | 1 dx2=# SELECT * FROM assets_device_entity where device_no like '%p010000000592652%' ; -[ RECORD 1 ]-----+------------------------- id | 1124767 device_no | p010000000592652 product_id | 90 device_version_id | status | 0 position | 4 position_id | 138021 parent_box_no | 868658033042785 create_time | 2018-05-28 13:44:15.281 update_time | 2019-03-17 10:40:00.649 assets_status | 0 abnormal_id | parent_type | 2 parent_id | 411903176171519561529084 device_status | 1 -[ RECORD 2 ]-----+------------------------- id | 1124767 device_no | p010000000592652 product_id | 90 device_version_id | status | 0 position | 3 position_id | 138021 parent_box_no | create_time | 2018-05-28 13:44:15.281 update_time | 2018-12-15 14:35:41.832 assets_status | abnormal_id | parent_type | 1 parent_id | 0 device_status | ``` 3. 疑惑 为什么我可以看到两行数据有相同的主键,求大神指教
我的签名:
trainee
回复: ...
... 2019-10-17 09:47:35+08...2楼
这个可能是bug, 也有可能数据被破坏了, 建议备份,重建数据库, 再恢复
我的签名:
您还没有登录,请您登录后再发表回复
© 2010 PostgreSQL中文社区