MySQL DML statement (insert update Delete)

Source: Internet
Author: User

DML is primarily for data in database table objects, and general DML is complete:

Inserting new data

Modifying data that has been added

Delete data that you do not need

1. Insert INTO insertion statement

//primary key self-increment can not be inserted, so use NULL insteadInsert  into Temp Values(NULL,'Jack', -);//Specify ColumnsInsert  into Temp(name, age)Values('Jack', A), with parentheses behind the surface, column names in parentheses, and values that write the value of the specified column name. When omitting column names means inserting all data, note that the order in which the values are inserted and the order of the columns need to be consistent. //set mode, you can also specify the columnInsert  into Temp SetId= 7, name= 'Jason';//the foreign key reference of the MySQL foreign key table can be inserted into the data can be null, without reference to the data of the primary table. //inserting data using subqueriesInsert  into Temp(name)SelectName fromclasses;//multi-row insertionInsert  into Temp Values(NULL,'Jack', A), (NULL,'Jackson', at);

2. Update modification Statement

Update basically completes the modification of the data, you can modify one or more data.

modifying multiple or specified criteria needs to be done with a where condition.

//Modify All DataUpdate Temp SetName= 'Jack2';//The name of all the data will be modified if multiple columns are modified with "," separateUpdate Temp SetName= 'Jack', age=  A;//changing the record for the specified condition requires a whereUpdate Temp SetName= 'Jack' whereAge>  A;

3. Delete Deletion statement

Delete all of the data in the table, with the condition that you can delete the specified record.

// Delete all data Delete  from Temp ; // Delete specified condition data Delete  from Temp where > ;

MySQL DML statement (insert update Delete)

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.