在PostgreSQL中自动索引主键? [英] is primary key automatically indexed in postgresql?

查看:90
本文介绍了在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中自动索引主键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆