Mysql DBA Advanced Operations Learning note-DML Data combat in the modified table

Source: Internet
Author: User
Tags dba

9.10 modifying data in a table

9.10.1 modifying the data in a fixed column of a specified condition in a table

1. Command syntax: Update table name SET field = new value,.... where condition (be sure to note the condition)

2. Modify the contents of the specified row field

A. Viewing the table to be modified

[email protected] 02:3907->select * from test;+----+-----------+| id | name  |+----+-----------+|  1 | wwnwan||  2 | zbf   ||  3 | lisi  ||  4 | woshishei ||  5 | nimei |+----+-----------+

B. Change the name of the line with ID 3 to Tiejun

[email protected] 02:5335->update test set name=‘tiejun‘ where id=3;Query OK, 1 row affected (0.10 sec)Rows matched: 1  Changed: 1  Warnings: 0[email protected] 02:5348->select * from test;+----+-----------+| id | name  |+----+-----------+|  1 | wwnwan||  2 | zbf   ||  3 | tiejun||  4 | woshishei ||  5 | nimei |+----+-----------+

9.10.2 modifying data for all rows in a table

Serious case (possible misoperation causes data to be looked into)

A. Changing data for all tables without conditions

[email protected] 02:5352->update test set name=‘tiejun‘;

Do not add conditions to be very careful, professional practice, be sure to ask the development of confirmation, if you send the development of the statement to be marked in parentheses, to prevent the DBA misunderstanding.

B. All data has been changed

[email protected] 03:0109->select * from test;+----+--------+| id | name   |+----+--------+|  1 | tiejun ||  2 | tiejun ||  3 | tiejun ||  4 | tiejun ||  5 | tiejun |+----+--------+

C. Restoring with backed-up data

It has been backed up before and is not backed up again.

[[email protected] ~]# mysql -usystem -pzbf666 wwn < /opt/zbf_bak.sql

The WWN here is that the database is not a table.

[email protected] 03:1044->select * from test;+----+-----------+| id | name  |+----+-----------+|  1 | wwnwan||  2 | zbf   ||  3 | lisi  ||  4 | woshishei ||  5 | nimei |+----+-----------+

Mysql DBA Advanced Operations Learning note-DML Data combat in the modified table

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.