Mysql common SQL statements (1) and mysqlsql statements

Source: Internet
Author: User

Mysql common SQL statements (1) and mysqlsql statements
[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;



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.