1。表结构相同的表,且在同一数据库(如,table1,table2) Sql :insert into table1 select * from table2 (完全复制) insert into table1 select distinct * from table2(不复制重复纪录) insert into table1 select top 5 * from table2 (前...
1. 表结构完全一样 insert into 表1 select * from 表2 2. 表结构不一样(这种情况下得指定列名) insert into 表1 (列名1,列名2,列名3) select 列1,列2,列3 from 表2
两张表:insertTest和insertTest2,前者中有测试数据 create table insertTest(id int(4),name varchar(12)); insert into insertTest values(100,'liudehua'); insert into insertTest values(101,'zhourunfa'); insert into insertTest values...
1. 表结构完全一样 insert into 表1 select * from 表2 2. 表结构不一样(这种情况下得指定列名) insert into 表1 (列名1,列名2,列名3) select 列1,列2,列3 from 表2
1. 表结构完全一样 insert into 表1 select * from 表2 2. 表结构不一样(这种情况下得指定列名) insert into 表(列名1,列名2,列名3) select 列1,列2,列3 from 表2
其实很简单,只是为了忘记,做个记录,用的时候方便。 不管是在网站开发还是在应用程序开发中,我们经常会碰到需要将MySQL或MS SQLServer某个表的数据批量导入到另一个表的情况,甚至有时还需要指定导入字段。 本文就将以MySQL数据库为例,介绍...
另一张表已经存在还是不存在 不存在可以 select * into 目标表 from 原表 另一张表存在 insert into 目标表 select * from 原表;
db1为原数据库,db2为要导出到的数据库,fromtable 是要导出的表名 1.方法一: 登录导出到的数据库,执行 create table fromtable select * from db1.fromtable; 2.方法二: 在cmd下执行,mysqldump -u root -p db1 fromtable file=d:/fromtable...
db1为原数据库,db2为要导出到的数据库,fromtable 是要导出的表名 1.方法一: 登录导出到的数据库,执行 create table fromtable select * from db1.fromtable; 2.方法二: 在cmd下执行,mysqldump -u root -p db1 fromtable file=d:/fromtable...
insert into b(tel) select mobile from a