Home > Database > Mysql Tutorial > What are the two ways to insert records in mysql

What are the two ways to insert records in mysql

PHPz
Release: 2023-05-29 13:26:23
forward
1596 people have browsed it

1. Insert the specified column. If the column is not listed, null is automatically assigned. If you do not insert a column and set a non-null constraint, an error will be reported.

2. Insert all columns. If you do not want to insert a value into any column, you need to assign it to null.

Example

insert into 表名 values(值,值....);           
 
eg:
insert into product values(null,'苹果电脑',18000.0,10);
insert into product values(null,'华为5G手机',30000,20);
insert into product values(null,'小米手机',1800,30);
insert into product values(null,'iPhonex',8000,10);
insert into product values(null,'iPhone7',6000,200);
insert into product values(null,'iPhone6s',4000,1000);
insert into product values(null,'iPhone6',3500,100);
insert into product values(null,'iPhone5s',3000,100);
 
insert into product values(null,'方便面',4.5,1000);
insert into product values(null,'咖啡',11,200);
insert into product values(null,'矿泉水',3,500);
Copy after login

The above is the detailed content of What are the two ways to insert records in mysql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
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