您的位置:首页 > 数据库

如何用SQL语句复制表和表中的数据?

2014-07-14 15:13 267 查看



--如何用SQL语句复制表和表中的数据?

select * into copytable from table1

--table1 源表

--copytable 要复制的表

sql 2005表的复制有两种:一种就是把整个表复制过去,就好像复制文件并且重命名。别外一种就是把表的内容复制过出.

select * into newtable form oldtable;把oldtabel复制到newtable且newtable不存在,否则出错.;
insert into newtable select * from oldtable把oldtable的内容插入到newtable, newtable一定要存在,才可以复制.不同数据库间复制表

if object_id('test') is not null drop synonym test

create synonym test for test.dbo.vdwl_product

select * into vdwl_product from test

select * from vdwl_product

#Sql Server
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: