-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
-- INDEX (BTree data structure) | ||
-- Indexes are used to find values within a specific column more quickly | ||
-- MySQL normally searches sequentially through a column | ||
-- The longer the column, the more expensive the operation is | ||
-- UPDATE takes more time, SELECT takes less time | ||
SELECT * FROM customers; | ||
|
||
SHOW INDEXES FROM customers; | ||
|
||
CREATE INDEX last_name_idx | ||
ON customers(last_name); | ||
|
||
SELECT * FROM customers | ||
WHERE last_name = "Puff"; | ||
|
||
CREATE INDEX last_name_first_name_idx | ||
ON customers(last_name, first_name); | ||
|
||
ALTER TABLE customers | ||
DROP INDEX last_name_idx; | ||
|
||
SELECT * FROM customers | ||
WHERE last_name = "Puff" AND first_name = "Poppy"; |