MySQL Common SQL statement (i)

Source: Internet
Author: User

"1" EMPTY table statement

TRUNCATE TABLE fke_message;


"2" resets the starting value of the Increment field
ALTER TABLE fke_message auto_increment = 10001;



"3" common build Table Statement

DROP TABLE IF EXISTS ' fke_message '; CREATE TABLE ' fke_message ' (  ' id ' int () NOT NULL auto_increment,  ' username ' varchar (+) NOT null DEFAULT ' COMM ENT ' username ',  ' tel ' varchar (a) NOT null default ' COMMENT ' phone number ',  ' email ' varchar (+) NOT null default ' ' COMMENT ' e-mail ',  ' msginfo ' varchar (255) NOT null default ' COMMENT ' message ',  ' createdate ' int (one) not null default ' 0 ' commen T ' timestamp ',  PRIMARY KEY (' id ')) engine=innodb DEFAULT Charset=utf8;



"4" Common query statements

1. Statistics User Volume

Select COUNT (Distinct ID) from Fke_member


2. Add Fields

ALTER TABLE E_down add soft_version1 varchar (+) not NULL default ';


3. Modify the field type

ALTER TABLE address modify column city varchar (n) 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;



MySQL Common SQL statement (i)

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.