Sobes.tech
Junior — Middle

Is explicit indexing required when defining a primary key in a database table?

sobes.tech AI

Answer from AI

When defining a primary key in a database table, explicit indexing is usually not required. This is because most DBMSs automatically create a unique index on columns declared as primary keys.

For example, in SQL:

CREATE TABLE users (
    id INT PRIMARY KEY,
    name VARCHAR(100)
);

In this case, the DBMS will automatically create a unique index on the id column, ensuring fast search and uniqueness of values. If an additional index or special indexing parameters are needed, they can be specified separately.