SQL DDL and DML/Create index

Add an index to improve lookup performance.

Section: Constraints and Indexes

Create index

sql
sql
CREATE INDEX idx_orders_customer_id
ON orders (customer_id);
Explanation

Indexes speed up reads but add write overhead and storage cost.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Constraints and Indexes
Create composite index
Index multiple columns together.
OpenIn sheetsqlsame section
Define primary key
Mark a column as the main row identifier.
OpenIn sheetsqlsame section
Define unique constraint
Ensure a column or column set stays unique.
OpenIn sheetsqlsame section
Add check constraint
Restrict column values with a boolean rule.
OpenIn sheetsqlsame section
Create table
Define a new table with columns and constraints.
OpenIn sheetsql1 tag match
Add a column
Modify an existing table by adding a new column.
OpenIn sheetsql1 tag match