03.22 mysql view index database backup export import

Indexes are an efficient way to combine data to quickly find specific records

The function
greatly improves the retrieval speed of the database

Improve database performance

MySQL indexes categorized by storage type

1. B-tree index: both InnoDB and MyISAM support --- binary method ---

Innodb is one of the database engines, the biggest feature is to support ACDI compatible transactions.

myisam: default storage index

2. Hash index: It is an algorithm that takes a number at random, divides all numbers by the number to obtain the remainder, and puts those with the same remainder together, subscripts 0, 1, 2... The remainder corresponds to the following table

There are multiple conditions in where, and the index condition is checked first.


index type:

Plain Index: The basic index type that allows insertion of duplicate and null values ​​in the column that defines the index

Unique index: The index column data is not repeated, and null values ​​are allowed

Primary key index: each value in the primary key column is non-null and unique, a primary key will automatically create a primary key index

Compound Index: Combines multiple columns as an index

Full-text index: supports full-text search of values, allows duplicate values ​​and null values, myisam support, innodb does not support.

Spatial index: Indexes built on columns of spatial data type are mostly used in maps.

Create an index:

CREATE [UNIQUE|FULLTEXT|SPATIAL] INDEX index_name

ON table_name (column_name[length]…);

Drop index:

DROP  INDEX index_name ON table_name;

Columns for indexing are selected based on the following criteria: Columns that are
frequently searched Columns that
are frequently used in queries Columns that
are frequently sorted, grouped

Columns often used as joins (primary key/foreign key)


Please do not create an index with a column that
contains only a few distinct values ​​in a
list with only a few rows


database backup:

mysqldump [options] –u username –h host –ppassword 

dbname[tbname1[,tbname2...]]>filename.sql#Operate under the dos command

Restoring the database:

1.mysql –u username –p [dbname] < filename.sql

2. Use the source command to restore the database

source filename;

Data export file:

SELECT  *  FROM tablename 
         [WHERE contion]

         INTO OUTFILE 'filename' [OPTION]

File to import into datatable:

 LOAD DATA INFILE filename INTO TABLE tablename [OPTION]

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325522228&siteId=291194637