Add, update and delete data in MySQL database -

jacklove
Release: 2023-03-31 16:44:01
Original
3356 people have browsed it

1. Add data

1. Add data for all fields in the table

(1) Specify all field names in the insert statement

(2) The insert statement does not specify a field name: the added value must cover all fields and be the same as the field The same order as defined in the table.

2. Add data to the specified field of the table

If a field is defined with a non-null constraint added , but no default constraint is added, then the field must be assigned a value when inserting a new record, otherwise the database system will prompt an error.

3. Add multiple records at the same time

## 2. Update data

1. Update some data

##2. Update all data

3. Delete data

1. Delete delete part of the data

2. Use the keyword truncate to delete data in the table: it can only be used to delete all records in the table.

Note: After using the truncate statement to delete the data in the table, when adding records to the table again, the default initial value of the automatically increased field will start from 1 again, while using delete After the statement deletes all records in the table, when adding records again, the value of the automatically increased field is the maximum value of the field when deleted plus 1.

This article explains adding, updating and deleting data in MySQL database, more For related content, please pay attention to php Chinese website.

Related recommendations:

$Selector--how to encapsulate DOM into jquery objects


Native js componentization Develop simple carousel chart example code


css3 animated navigation bar 3D

The above is the detailed content of Add, update and delete data in MySQL database -. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!