//把emp表中的所有数据插入到emp表中
insert into emp select * from emp;
//把emp表中的部分字段插入emp表中
insert into emp (name,sex) select name,sex from emp;
注意:1、通过反复执行以上sql,可以获得大量的数据库数据
2、当所用表有主键时,或者有唯一性约束时,就不能使用第一种写法,因为插入的数据是重复的,违反的唯一性,会报 错!
//把emp表中的所有数据插入到emp表中
insert into emp select * from emp;
//把emp表中的部分字段插入emp表中
insert into emp (name,sex) select name,sex from emp;
注意:1、通过反复执行以上sql,可以获得大量的数据库数据
2、当所用表有主键时,或者有唯一性约束时,就不能使用第一种写法,因为插入的数据是重复的,违反的唯一性,会报 错!