Summary of MySQL BASIC statement

Source: Internet
Author: User

1---------------Create a table------------------------------------

drop table if exists tables name

CREATE TABLE table name (ID int (one) primary key auto_increment, name varchar () not NULL); 2---------------Modify the table name of a table------------------------------------ALTER TABLE name 1 rename to table Name 2 explanation: Change table name 1 to table name 2demo:
ALTER TABLE TA1 Rename to ta0; 3---------------Add a field------------------------------------the name of the Alter table table name of the Add Column field varchar (a) NOT NULL default 1 Comment ' Interpretation of this field ' after the other fields are explained: After, the new field has a sort effect after the After field name segment. 4---------------Delete a field------------------------------------ALTER TABLE name drop field Name 5---------------Delete data/ Library (delete only data structures do not delete-----Drop is the entire table is deleted, including the table's data and the structure of the table. Truncate is the first to delete the entire table, in the establishment of the table structure, the data will be lost)------------------------------------drop database "name"; TRUNCATE TABLE name//delete data in table. "Free space, id resets" Delete from table name "row by row of deleted data, does not free up space, you can find that the ID of adding data data again is constantly superimposed" 6--------------- Modify field name------------------------------------ALTER TABLE name change old field new field varchar demo:alter table ta0 change names NA Me varchar (20); 7---------------Modify the field type------------------------------------ALTER TABLE name modify the new Type of Field field Demo:
ALTER TABLE TA0 modify uname int; 8----------------Query Statement-----------------------------------SELECT * FROM table name where + condition 9---------------- Insert statement-----------------------------------(1) INSERT into Table name values (field);
Demo
INSERT into TA1 values (1, ' 2 ');
(2) Insert into table name (field name) values (corresponding values);
Demo
Insert into TA1 (Id,username) VALUES (2, ' scatter '); ----------------UPDATE statement-----------------------------------the updated table name set field name = Value Demo:update ta1 set username= ' 4 ';

Summary of MySQL BASIC statement

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.