1、插入指定列,如果没有列出这个列,自动给null赋值。如果不插入列,设置非空约束,会报错。
2、插入所有列,如果哪个列不想插入值,就需要赋值为null。
实例
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);
以上就是mysql插入记录的两种方式,希望对大家有所帮助。更多mysql学习指路:
推荐操作系统:windows7系统、mysql5.8、DELL G3电脑