MySQL Operation statement

Source: Internet
Author: User

//Create a database (the end of MySQL statement in PHP is not added, because the MySQL tone in PHP can only execute one sentence at a time)Create Databasetestdatabase;//Select Database Usetestdatabase;//Create a data tableCreate TableTest_table (first_namevarchar( -), last_namevarchar( -));//inserting data into a data tableInsert  intoTest_table (First_name,last_name)Values('Sally','Jones');
That's not good.
insert into test_table values(' Sally ',' Jones ');//Querying DataSelect * fromtest_table;SelectFirst_Name fromtest_table;SelectFirst_Name fromTest_tablewhereFirst_Name='Sally';//emptying data table dataDelete fromtest_table;//Delete data table row dataDelete fromTest_tablewhereFirst_Name='Sally' orLast_Name='Jones';//Delete a data tableDrop Tabletest_table;//Deleting a databaseDrop Databasetestdatabase;//add a column to the data tableAlter TableTest_tableAddIdint;//add a column to the data table and set the primary key (not empty, self-increment, at the front of the table)Alter TableTest_tableAddIdint not NULL auto_increment First,Add Primary Key(ID);//to delete a column in a data tableAlter TableTest_tableDrop columnfirst_name;//Modify column names and data types for a column in a data tableAlter TableTest_table Change columnFirst_Name Middle_nameChar;//Modify the column name of the data table column, locationAlter TableTest_tableModify columnfirst_name middle_name;Alter TableTest_tableModify columnfirst_name first;Alter TableTest_tableModify columnLast_Name AfterMiddle_name;

MySQL Operation statement

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.