问题
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