Definition of index: An index is also a DDL object, created with the create keyword
What can indexed do:
select *from emp where salary >15000; |
Query process: At this time, the database will perform a full table scan, which is a row-by-row scan, and those that meet the conditions will stay. Until all rows of a table are scanned, the query results are returned |
How can we not query the whole table and improve efficiency? To create an index, you must set a specified field Index syntax: CREATE INDEX index name ON table name (field); Example: CREATE INDEX emp_sal_index ON enp(sal); After the index is created, select *from emp where salary >15000; the query statement is to query the field of sal, and the full table query will not be performed. |