PG中文社区 /
mdi-home
首页
社区新闻
中文文档
加入ACE
相关资料
mdi-chevron-down
{{ item.text }}
登录
mdi-home
首页
mdi-chat-processing
社区新闻
mdi-book-open-variant
中文文档
mdi-account-multiple-check
加入ACE
mdi-file-multiple-outline
相关资料
mdi-blank
{{item.text}}
mdi-exit-to-app
退出账号
首页
-->
有问有答
-->
其他
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, 也有可能数据被破坏了, 建议备份,重建数据库, 再恢复
我的签名:
您还没有登录,请您登录后再发表回复
加入我们
QQ群1:5276420
QQ群2:3336901
QQ群3:254622631
文档群:150657323
文档翻译平台:
按此访问
社区邮件列表:
按此订阅
商业支持
成都文武信息技术有限公司
杭州乘数科技有限公司
阿里云
华为云
青云(北京优帆科技有限公司)
扫码关注
加入我们
QQ群1:5276420
QQ群2:3336901
QQ群3:254622631
文档群:150657323
文档翻译平台:
按此访问
社区邮件列表:
按此订阅
商业支持
成都文武信息技术有限公司
杭州乘数科技有限公司
阿里云
华为云
青云(北京优帆科技有限公司)
扫码关注
© PostgreSQL中文社区 ... (自2010年起)