MS SqlServer:Select column1,column2…… into Table2 From Table1 或 Select * into Table2 From Table1
例:
--Oracle --1.创建表 create TABLE Table1 ( a varchar(10), b varchar(10), c varchar(10) ) ; commit; --2.创建测试数据 Insert into Table1 values('赵','asds','90'); Insert into Table1 values('钱','asds','100'); Insert into Table1 values('孙','asds','80'); Insert into Table1 values('李','asds',null); commit; --3.复制table1数据到table2中 Create Table Table2 as select a,b,c From table1; Commit; --或(这两种方式的sql只能应用一次) Create table table2 as select * From Table1; Commit; --删除表 drop table table1; drop table table2; commit;
--MS SqlServer --1.创建表 create TABLE Table1 ( a varchar(10), b varchar(10), c varchar(10) ) ; commit; --2.创建测试数据 Insert into Table1 values('赵','asds','90'); Insert into Table1 values('钱','asds','100'); Insert into Table1 values('孙','asds','80'); Insert into Table1 values('李','asds',null); commit; --3.复制table1数据到table2中 Select a,b,c into Table2 From table1; Commit; --或(这两种方式的sql只能应用一次) Select * into table2 From Table1; Commit; --删除表 drop table table1; drop table table2; commit;
到此这篇关于SQL Server之SELECT INTO 和 INSERT INTO SELECT案例详解的文章就介绍到这了,更多相关SQL Server之SELECT INTO 和 INSERT INTO SELECT内容请搜索
更多SQL内容来自木庄网络博客