在PostgreSQL中自动索引主键?

编程入门 行业动态 更新时间:2024-10-10 14:27:10
本文介绍了在PostgreSQL中自动索引主键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经用ID列作为主键创建了表名d,然后按输出中所示插入了记录,但是在获取所有记录后,此输出仍显示与插入记录的顺序相同.但现在输出的结果不是按顺序排列的.

I have created table name as d with ID column as primary key and then just inserted records as shown in output, but after fetching all records this output still displayed same as order in which records are inserted. but output as a see now not in ordered form.

推荐答案

PostgreSQL会为每个唯一约束和主键约束自动创建一个索引以强制执行唯一性.因此,没有必要为主键列显式创建索引.(有关更多信息,请参见CREATE INDEX.)

PostgreSQL automatically creates an index for each unique constraint and primary key constraint to enforce uniqueness. Thus, it is not necessary to create an index explicitly for primary key columns. (See CREATE INDEX for more information.)

来源:文档

更多推荐

在PostgreSQL中自动索引主键?

本文发布于:2023-10-14 03:50:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1489939.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:主键   索引   PostgreSQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!