INDEX ON PRIMARY KEY
INDEX ON PRIMARY KEY is a SQL statement in the Indexes category. A PRIMARY KEY constraint automatically creates a unique index. In InnoDB, the PK index IS the table (clustered). The syntax is -- Primary key automatically creates a unique clustered/nonclustered index.. It returns pK index created. A typical example: CREATE TABLE employees ( id INT PRIMARY KEY, name VARCHAR(100) ); -- Automatically creates unique index on id -- In MySQL/InnoDB: -- - PRIMARY KEY = clustered index (data stored in index order) -- - Secondary indexes reference the PK value -- In PostgreSQL: -- - PRIMARY KEY creates a unique B-tree index -- - Data is stored as heap (not index-ordered) -- - Secondary indexes reference physical row location… A close relative is CREATE INDEX, which creates an index on one or more columns to speed up query performance. A close relative is DROP INDEX, which removes an existing index from a table.