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 and flow from this site, held on your device and searchable with no connection. Free to install, no ads.

Get it free on the App Store