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
PHPzforward
2023-05-29 13:26:231602browse

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);

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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete