Ddy 44 storage engine indexing rights

Storage Engine

1. What is the storage engine: refers to how data is stored, how to index data stored and how to update, query data and other implementation technologies.

Storage Engine Category

1.innodb

 1. Default version 5.6 include

 2. Support operations using things

 3. does not support full-text indexing

 4. The index data and are in the same file, .idb

2.MyIsam

1. The following default version 5.5

2. Operation of things not supported

3. Support full-text index

4. .frm table structure

    .MYD table data

    .MYI table index

3.memory

index

1. What is the index:索引是一种特殊的文件(InnoDB数据表上的索引是表空间的一个组成部分),它们包含着对数据表里所有记录的引用指针。更通俗的说,数据库索引好比是一本书前面的目录,能加快数据库的查询速度。

2. Role: speed up queries

classification

1. primary key index

 Primary key index: speed up queries; can not be repeated; can not be null; primary key

 Primary key index:
# The first:
# Create Table T1 (
# AUTO_INCREMENT ID int Primary Key,
# name VARCHAR (32) Not null default ''
#) = Engine Innodb charset = UTF8;
# a second:

# alter table t1 change id id int auto_increment primary key;

 

2. The only index

The only index: speed up queries; can not be repeated; unique (column name)

United unique index: speed up queries; can not be repeated; unique (column name, column name)

Unique index: 
# The first:
# Create Table T1 (
# AUTO_INCREMENT ID int Primary Key,
# name VARCHAR (32) Not null default '',
# UNIQUE the ix_name ( 'name')
#) = Engine Innodb charset = UTF8;
#
The second #:
# the Create UNIQUE index index name (ix_name) on the table name (T1) (name);
# the Create UNIQUE index index name (ix_name_age) on the table name (t1) (name, age) ;

3. The general index

Ordinary Index: speed up queries

Common Index: 
#
# The first:
# Create Table T1 (
# AUTO_INCREMENT ID int Primary Key,
# name VARCHAR (32) Not null default '',
# the ix_name index ( 'name')
#) = Engine Innodb charset = UTF8;
#
# The second:
# the Create index index name (ix_name) on the table name (t1) (name);

4. Delete Index

drop index index name (ix_name) on the table name (t1);

The disadvantage Index

Version 5.3 of the following: 
# delete and modify the speed is slower
#
# version 5.5:
# delete and modify the speed is not particularly slow
 
  

6.explain

1. Role: sql statement to see whether the index and efficiency

2. Use: explain sql statement Example: explain select * from where id = 1 \ G

 
  

7.SQL statement rules


#
# - not recommended like search
# - most left-prefix composite index
# If the composite index is: (name, Email)
# the WHERE name and Email - Use Index
# where name - the use of index
# where email - do not use index
 
  

Slow query log

1. Log Files: record execution particularly slow sql statement

2. How to use:

Variables like Show 1. '%% Query'; 
#
# = 2. SET Global long_query_time. 1; slow query time setting
# = 3. slow_query_log the ON
# 4. slow_query_log_file = E: \ Program \ MySQL-5.6.44-Winx64 \ data \ oldboy-slow.log
 
  

Ordinary Log Query

show variables like '%general%';
# +------------------+------------------------------------------------+
# | Variable_name | Value |
# +------------------+------------------------------------------------+
# | general_log | ON |
# | general_log_file | E:\program\mysql-5.6.44-winx64\data\oldboy.log |
# +------------------+------------------------------------------------+
# set global general_log = ON;
 
  

authority management

Create a user 
# create user 'username' @ 'IP address' identified by' password ';
# creaee the User' zekai'@'192.168.1.123 'identified by' 123qwe ';
# creaee the User' zekai'@'192.168.1. % 'IDENTIFIED by' 123qwe ';
# the Create the user' Zekai '@'% 'IDENTIFIED by' 123qwe ';
#
# delete user
# drop user' username '@' IP address ';
# modify user
# rename user' user name '@' IP address' to 'new user name' @ 'IP address';
#
# Change password
# set password for' username '@' IP address' = password ( 'new password')
#
# authorization:
# Grant permissions on database tables to 'user' @ 'IP address' - authorization
#
# Grant the SELECT on db1.* to 'zekai'@'%';
# grant select on *.* to 'zekai'@'%';
# grant select, insert, delete on db1.* to 'zekai'@'%';
#
# Remember:
# flush privileges;
 
  

 



 

Reproduced in: https: //www.cnblogs.com/tfzz/p/11040233.html

Guess you like

Origin blog.csdn.net/weixin_33829657/article/details/93794238