Mysql Index (simple to understand)

Mysql storage engine, can use different storage engines for different tables

  MyISAM: insert, check the fast speed of blood, but is not supported, so it is suitable for data warehousing, Web, etc.

  InnoDB: support, so it is suitable for things databases

  Memory: the data is stored in memory

  Archive: something unsafe, so it can be used to save the log or something

Each engine careful there are many features available can see

----------------------------------------------------------------------------------  

index

  Mysql storage engine, there are two B-tree and Hash 

  Advantage of the index: the index can be more than one column or row for a specified speed up queries

        Or the packet may be reduced execution time sorting clause

 

  The disadvantages of index: much of the memory

        When modifications to the table to increase deleted, the corresponding index also need to change

  Classification index: separate index and combination index

          A separate index refers to the index only one column, but a table can have multiple separate index

          The index is a composite index finger on the table to create multiple fields

  Full-text indexing: Find all supported values, allowing repeated and null

  Create an index: create table in the establishment of

  Simply create an index on a column

Check whether the index is successfully created

 

select_type refers to the type of select such simple queries, sub-queries, the joint inquiry

Table name table query

partitions when partition table needs

The relationship between type table

possible_keys index (optional)

The actual use of the index key

Key_len index length (in bytes)

ref relationship in another table column names

The number of rows is expected to read data line

Extra association operation information

Create a unique index

The default name is the unique index id (default column name)

Create a separate index

Create Composite Index

Create a full-text index: keyword FULLTEXT, can only use the type of varchar char Text

 If the table already exists

  1. Create an index using the ALTER TABLE

   grammar

   ALTER TABLE table_name ADD [UNIQUE|FUUTEXT|SPATIAL]
   [INDEX|KEY] [index_name] (col_name[length],...) [ASC|DESC]
   ALTER TABLE tabletest ADD UNIQUE INDEX (id);
   给tabletest对id列添加唯一索引,名字是id,如果要指定名字后边改成这个 UniqueId(id),意思是添加唯一索引,名字是UniqueId

   2.使用CREATE INDEX创建索引

           语法

  CREATE [UNIQUE|FULLTEXT|SPATIAL] INDEX index_name ON table_name(col_name[length],...)[ASC|DESC]
  CREATE UNIQUE INDEX UniqueId ON tabletest(id)
  在tabletest上对id列创建唯一索引,名字是UniqueId

删除索引
  1.ALTER TABLEF
  语法
  ALTER TABLE table_name DROP INDEX index_name
  2.DROP INDEX
  语法
  DROP INDEX index_name on table_name



----------------------内容很不完善,后续有空会慢慢补充--------------------------------------

Guess you like

Origin www.cnblogs.com/fjd-1004/p/11030876.html