Must the search key of a primary index be or related to the primary key?

独自空忆成欢 提交于 2019-12-11 17:46:42

问题


From https://stackoverflow.com/a/51087864/3284469

primary keys can be primary indices.

Must the search key of a primary index be or related to a primary key ? Will the answer be different in PostgreSQL and other DBMS? Thanks.


回答1:


Postgres doesn't have "primary index", all indexes are implemented the same way, and point directly to the data rows.

Must the search key of a primary index be or related to a primary key

It must be a search on the expression used to form the primary index. if the primary index is constrained to be an index on the primary key then yes else no.

Will the answer be different in PostgreSQL and other DBMS?

yes, because postgresql does not have primary index. although a clustered index is a bit like a primary index. the clustered index can be an index on on any expression, it need not reference the primary key at all.

with postgreql there is no requirement that a table have any index. but if you want to define relations between tables then indexes are required.



来源:https://stackoverflow.com/questions/51128629/must-the-search-key-of-a-primary-index-be-or-related-to-the-primary-key

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!