SQL-W3School- High: SQL CREATE INDEX statement

ylbtech-SQL-W3School- High: SQL CREATE INDEX statement

 

1. Back to top
1、

CREATE INDEX statement to create an index in the table.

In the case without reading the entire table, index the database application can find data faster .

index

You can create an index in the table, in order to more quickly and efficiently query data.

The user can not see the indexes, they can only be used to speed up the search / query.

Note: more new index contains a table requires more than update a table with no indexes more time , this is because the index itself needs to be updated . Therefore, the ideal approach is only in the column often searched (and table) to create an index above .

SQL CREATE INDEX Syntax

Create a simple index on a table. It allows the use of duplicate values:

CREATE INDEX index_name
ON table_name (column_name)

Comment: "column_name" provisions need to be indexed columns.

SQL CREATE UNIQUE INDEX syntax

Create a unique index on the table. Unique index means that two rows can not have the same index value.

CREATE UNIQUE INDEX index_name
ON table_name (column_name)

Examples of CREATE INDEX

This regular meeting to create a simple index, named "PersonIndex", in LastName Person table columns:

CREATE INDEX PersonIndex
ON Person (LastName) 

If you want to descending index value of a column, the column names you can add the reserved word DESC after :

CREATE INDEX PersonIndex
ON Person (LastName DESC) 

If you want to index more than one column, you can list the names of columns in parentheses, separated by commas:

CREATE INDEX PersonIndex
ON Person (LastName, FirstName)
2、
2. Return to top
 
3. Back to top
 
4. Top
 
5. Top
1、
2、
 
6. Back to top
 
warn Author: ylbtech
Source: http://ylbtech.cnblogs.com/
This article belongs to the author and blog Park total, welcome to reprint, but without the author's consent declared by this section must be retained, and given the original connection in the apparent position of the article page, otherwise reserves the right to pursue legal responsibilities.

Guess you like

Origin www.cnblogs.com/storebook/p/11824476.html