Mysql add, delete, modify and query insert records
There are two basic syntaxes for inserting records
Inserting basic syntax one
Category
Detailed explanation
Basic syntax
insert into table values(value 1, value 2, value n);
Example
INSERT INTO user values(2,'php中文网','male')
Example description
Into the user table The inserted value id is 2, the name is Li Wenkai, and the gender is male
Insert basic syntax two
##Category
Detailed explanation
Basic syntax
insert into table (field 1, field 2, field n) values (value 1 , value 2, value n);
Example
INSERT INTO user(id,username,sex) values(213,'小Shenyang',1);
Example description
Insert the id 213 into the user table, the username is Xiaoshenyang, and the gender is 1
DescriptionThe difference between basic syntax 1 and basic syntax 2 is: In the insert statement of basic syntax 1, as many values as there are fields in the table must be inserted. No one can be more, and no one can be less. If there is a default value and you don’t want to pass it, you can write null. In basic syntax 2, unless there are required fields, values must be written. If you don't want to write a default value, you can ignore it. mysql will automatically supplement the default value. In basic syntax 2, the order of user(id,username,sex) fields is the order of values. Assume that there is a table called the user table. We describe the fields, field descriptions, types, and field optional and required states. The table structure is as follows:
The courseware is not available for download at the moment. The staff is currently organizing it. Please pay more attention to this course in the future~
Students who have watched this course are also learning