sqlcmd.net validated sql reference
intermediate defining MySQL MariaDB SQL Server PostgreSQL SQLite

Remove an Index With DROP INDEX

Drop an index that is no longer useful so writes no longer have to maintain it.

Docker-validated Not currently validation-green

Drop an unused status index and keep the table rows

Dropping the index removes only the lookup structure. The orders rows remain available, which the final SELECT confirms.

MySQL MariaDB SQL Server
Engine-specific syntax
Setup
CREATE TABLE orders (id INT, status VARCHAR(20));

INSERT INTO
  orders
VALUES
  (1, 'open'),
  (2, 'closed');

CREATE INDEX idx_orders_status ON orders (status);
SQL
DROP INDEX idx_orders_status ON orders;

SELECT
  id,
  status
FROM
  orders
ORDER BY
  id;
idstatus
1open
2closed
PostgreSQL SQLite
Engine-specific syntax
Setup
CREATE TABLE orders (id INT, status VARCHAR(20));

INSERT INTO
  orders
VALUES
  (1, 'open'),
  (2, 'closed');

CREATE INDEX idx_orders_status ON orders (status);
SQL
DROP INDEX idx_orders_status;

SELECT
  id,
  status
FROM
  orders
ORDER BY
  id;
idstatus
1open
2closed

MySQL and MariaDB name the table in `DROP INDEX`; PostgreSQL and SQLite drop by index name.

Where this command helps.

  • removing an unused performance index after query patterns change
  • cleaning up duplicate or redundant indexes during schema maintenance

What the command is doing.

DROP INDEX removes an index from a table while leaving the table data intact. Dropping an index can reduce write overhead and storage when the index no longer supports real queries. Do not drop indexes used to enforce primary keys or unique constraints unless you intend to remove that integrity rule too.