0

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.

  • Hi. Indexes are not part of standard SQL & depend on the particular DBMS. What did you learn researching in the manual? What part of that other question is relevant?--please make this & all questions self-contained. – philipxy Jul 04 '18 at 23:49

1 Answers1

0

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.

Jasen
  • 11,087
  • 2
  • 27
  • 46