SQL Advanced App (CREATE INDEX)

Source: Internet
Author: User

SQL CREATE INDEX Statement

CREATE INDEX statement for creating indexes in tables

  Enables database applications to find data faster without reading the entire table

You can create indexes in tables to query data more quickly and efficiently

Users cannot see the index, they can only be used to speed up search/query

  Note: Updating a table that contains an index requires more time than updating a table that does not have an index, because the index itself needs to be updated. Therefore, it is desirable to create an index only on columns (and tables) that are often searched

  

SQL CREATE INDEX Syntax

Create a simple index on a table that allows duplicate values to be used

CREATE Idnex Index_nameon table_name (column_name)

Note: "column_name" specifies the columns that need to be indexed

SQL CREATE UNIQUE INDEX syntax

Creates a unique index on the table. A unique index means that two rows cannot have the same index value

CREATE UNIQUE INDEX Index_nameon table_name (column_name)

  

CREATE INDEX Instance

Create a simple index, named "Personindex", in the LastName column of the persons table

CREATE INDEX Personindexon Persons (LastName)

If you want to index a value in a column in descending order, you can add a reserved word after the column name DESC

CREATE INDEX personindexon person (LastName DESC)

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

CREATE INDEX personindexon person (LastName, FirstName)

  

SQL Advanced App (CREATE INDEX)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.