| Data Manipulation |
| |
| Create Index |
| |
| Indices are created in an existing table to locate rows more quickly and efficiently. It is possible to create an index on one or more columns of a table, and each index is given a name. The users cannot see the indexes; they are just used to speed up queries. |
| |
| Note: Updating a table containing indexes takes more time than updating a table without, this is because the indexes also need an update. So, it is a good idea to create indexes only on columns that are often used for a search. |
| |
| |
| A Unique Index |
| Creates a unique index on a table. A unique index means that two rows cannot have the same index value. |
| |
|
| |
| The "column_name" specifies the column you want indexed. |
| |
| A Simple Index |
| Creates a simple index on a table. When the UNIQUE keyword is omitted, duplicate values are allowed. |
| |
|
| |
| The "column_name" specifies the column you want indexed. |
| |
| Example |
| This example creates a simple index, named "PersonIndex", on the LastName field of the Person table: |
| |
|
| |
| If you want to index the values in a column in descending order, you can add the reserved word DESC after the column name: |
| |
|
| |
| If you want to index more than one column you can list the column names within the parentheses, separated by commas: |
| |
|
| |
| |
|
|
| |
| |