Sobes.tech
Junior — Middle

Is indexing mandatory for the primary key in a database table?

sobes.tech AI

Answer from AI

Yes, indexing for the primary key in a database table is mandatory. When you declare a column or a set of columns as a primary key, the DBMS automatically creates a unique index on this key. This is necessary to ensure the uniqueness of values and for efficient searching, updating, and deleting of records by the primary key.

Without an index, searching by the primary key would be very slow, as it would have to scan the entire table. An index allows for quickly finding the needed rows.

Is indexing mandatory for the primary key in a… - sobes.tech