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
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
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;
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