SQL Index
- Indexes are special lookup tables. It is used to retrieve data from the database very fast.
- An Index is used to speed up select queries and where clauses. But it shows down the data input with insert and update statements. Indexes can be created or dropped without affecting the data.
- An index in a database is just like an index in the back of a book.
Create Index statement
CREATE INDEX index_name ON table_name (column1, column2, ...);
Unique Index statement
Syntax
CREATE UNIQUE INDEX index_name ON table_name (column1, column2, ...);
Example
CREATE UNIQUE INDEX websites_idx ON websites (site_name);
Drop Index Statement
Syntax
DROP INDEX index_name;
Example
DROP INDEX websites_idx;
Comments
Post a Comment