Mysql common SQL statements (1)
[1] Clear TABLE statement
truncate table fke_message;
[2] resetting the start value of the auto-increment Field
alter table fke_message auto_increment = 10001;
[3] common table creation statements
Drop table if exists 'fke _ message'; create table 'fke _ message' ('id' int (10) not null AUTO_INCREMENT, 'username' varchar (40) not null default ''comment 'username', 'tel 'varchar (20) not null default ''comment 'phone number', 'email 'varchar (40) not null default ''comment' email address, 'msginfo' varchar (255) not null default ''comment' message ', 'createdate' int (11) not null default '0' comment' timestamp ', primary key ('id') ENGINE = InnoDB default charset = utf8;
[4] common query statements
1. count the number of users
select count(distinct id) from fke_member
2. Add Fields
alter table e_down add soft_version1 varchar(50) NOT NULL default '' ;
3. Modify the field type
alter table address modify column city varchar(50) NOT NULL default '';
4. Add an index
alter table member add index id_index(id);
[5] database creation statement
create database test default CHARACTER SET utf8 COLLATE utf8_general_ci;