MySQL database Add, update, and delete data-

Source: Internet
Author: User
One, add data

1. Add data to all fields in the table

(1) Specify all field names in the INSERT statement

(2) INSERT statement does not specify field name: The added value must overwrite all fields and the same order as the fields are defined in the table.

2. Adding data to a specified field in a table

If a field adds a non-null constraint when defined, but does not add a default constraint, the field must be assigned a value when the new record is inserted, or the database system will prompt for an error.

3. Add more than one record at a time

Second, update the data

1. Update updates some data

2. Update all data

Third, delete data

1. Delete Deletes part of the data

2. Delete data from a table using the keyword truncate: can only be used to delete all records in a table.

Note: After you use the TRUNCATE statement to delete data from a table, when you add records to the table again, the default initial value of the auto-increment field starts again at 1, and when you add a record by using the DELETE statement to delete all the records in the table, the value of the field is incremented by 1 when it is deleted.

This article explains the MySQL database add, update and delete data, more relevant content please follow the PHP Chinese web.

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.