MySQL数据插入方式汇总

mysql插入有多种方式,下面简单介绍一下

insert value 插入

insert into test(name,age) values("张三",20);

insert select 插入

insert into test(name,age) select name,age from test2;

insert set 插入

insert into test set name = "张三", age = 20;

replace into 插入

REPLACE INTO test (name,age) VALUES ("张三", 15);

insert ingore into

INSERT IGNORE INTO test VALUES(1,"张三",20),(6,"张三", 15);

批量插入

insert into test values("张三",20),("李四",20)m("王五", 18);