The establishment of normal indexes and the sorting of ordinary indexes

Source: Internet
Author: User
Tags index sort

This article for Bo Master Original, reproduced please indicate the source:


When the index is actually applied, an indexed SQL is added to the SQL in the table, and the application example is as follows:

CREATE TABLE tbl_camera_info (' cameraid ' varchar ( -) Not NULL COMMENT'lens unique number, unified monitoring platform', ' cameraname ' varchar ( -) Not NULL COMMENT'Lens name', ' clientId ' varchar ( -) Not NULL COMMENT'Customer number', ' clientName ' varchar ( -) DEFAULT NULL COMMENT'Owning Customer name', ' lasttime ' dateTime not NULL COMMENT'Last Modified Time', PRIMARY KEY (' Cameraid ', ' clientId ')) ENGINE INNODB DEFAULT CHARSET=utf8 comment='Lens Information Table';

A unique composite index of the Cameraid and ClientID's primary keys established above.

CREATE TABLE ' report_info ' (' ID ')int( One) Not NULL auto_increment COMMENT'self-increment sequence', ' cameraname ' varchar ( the) Not NULL COMMENT'Monitoring Point Name', ' clientName ' varchar ( the) Not NULL COMMENT'Customer Name', ' platid ' varchar (2) Not NULL COMMENT'Platform ID', ' Createtime ' datetime not NULL COMMENT'Opening Hours', ' Lasttime ' datetime not NULL COMMENT'Last update Time', PRIMARY KEY (' id '), index Report_camera_platid (platid ASC), index Report_camera_createtime (createtime DESC) ) ENGINE=innodb DEFAULT Charset=utf8 COMMENT ='Escalation Information Table';

The above table establishes the primary key index for the ID, the normal index, and adds the sort type for the normal index.


Physical sorting is the physical location where the records are stored, and the index sort is the equivalent of adding a book to the

A detailed directory (this directory can be based on the required requirements to determine the order, it is not recorded

The actual content recorded in the library, but only the location of each record in the library. Therefore, the amount of space required to build the index

is much smaller than physical sorting, and helps prevent data redundancy and the resulting data updates easily

resulting in inconsistencies in the data.

Establishment of normal indexes and sorting of ordinary indexes

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.