JAEN

SQL

CREATE INDEX

CautionCreate an index

CREATE INDEX <name> ON <table>(<col>);

Creates an index to speed up queries; remedy for slow queries.

Examples

  • CREATE INDEX idx_uid ON orders(user_id);Index on user_id

Syntax

CREATE INDEX <name> ON <table>(<cols>);

Before you run it

On large tables it can be slow and lock.

Used when you see

Slow database queries
3
Design and add the missing index
See the whole flow →

Related commands

The same reference, with no signal at all

Every command on this site, held on your device. The app adds 632 more: 1,510 commands and 120 fix flows, searchable with no connection. Free to install, no ads (some content is a one-time purchase).

Get it free on the App Store