SQL from zero to quickly mastering "Data Update"

Source: Internet
Author: User

1. Import table in the same format as the two tables, import data from one table into another table.

There are now two records in the Person_old table. Next, insert all the records from the Person_old table into the person table, with the following statement:

INSERT into person (id,name,age,info)

SELECT Id,name,age,info from Person_old;

2. "Modify multiple rows of data"

In the person table, update the records with an age value of 19 to 22, change the Info field value to student, and open the Query editing window with the following statement.

SELECT * from the person WHERE age between and 22; --Select Object

UPDATE person SET info= ' student ' WHERE age between 22;

3. "Modify field data for all records"

In the person table, change the value of the info field for all records to VIP, as in the following statement.

SELECT * from person;

UPDATE person SET info= ' VIP ';

4, "Delete part of data"

In the person table, delete the record with age equal to 22, with the following statement.

SELECT * from person;

DELETE from the person WHERE age=22;

5. "Delete all data in the table"

SELECT * from person;

DELETE from person;

SQL from zero to quickly mastering "Data Update"

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.