Home >Database >Mysql Tutorial >Commonly used basic operation syntax of mysql (3)~~ Add, delete and modify data [command line mode]
1. Insert a single piece of data: insert into tablename (field name 1, field name 2,...) values (value 1, value 2,...);
As can be seen from the figure, every field does not need to have a value when inserting (provided there are no relevant constraints), but it should be noted that the number of fields and the number of subsequent values must be consistent. The order and type of the custom fields must also be consistent, otherwise an error will be reported. In addition, if no fields are specified, all fields are selected by default. Each field must have a corresponding value, and the order must be consistent with the fields in the table, otherwise an error will be reported, as shown in the figure:
2. Insert multiple pieces of data: insert into tablename (field 1, field 2) values (field 1 value, field 2 value) value),(field 1 value, field 2 value),(field 1 value, field 2 value)...;
## 4. Modify and update the data: update tablename set field name 1 = value 1, field name 2 = value 2...; if no conditions are added later, all
## will be updated.
# You can also add conditions later to update the data that meets the conditions:
5 , Delete data (record): delete from tablename where ...;
You can also not specify the conditions, so that all data will be deleted. In actual use, it may Just clear the data and use it. Normally, conditions will be added:
The above is the common basic operation syntax of mysql (3)~~Add, delete and modify operations on data [ Command line mode] content, for more related content, please pay attention to the PHP Chinese website (www.php.cn)!