把一张表的数据批量插入到另外一张表

时间:2021-01-16 00:53:18
<%
Server.ScriptTimeOut=600
Set conn=Server.CreateObject("ADODB.Connection")
if err.number<>0 then 
err.clear
    else
conn.open "Driver={SQL Server};Server=local,1433;UID=sa;PWD=!~@~@#$$432234$$543!;database=DATA;"
   end if

set rs=server.createobject("adodb.recordset")
rs.open "select CI_Keywords from TE_CorpInfo where ci_id > 13000 and ci_id<14000",conn,1,1  
if not rs.eof and not rs.bof then
for i=1 to rs.recordcount
'response.Write(rs.recordcount)
'response.end
aaa= rs.fields("CI_Keywords").value
bbb=split(aaa," ")
for j=1 to ubound(bbb)-1
set rskey = server.CreateObject("Adodb.Recordset")
rskey.open "select * from SS",conn,1,3 
rskey.addnew
rskey("KeyName")= bbb(j)
rskey.update
rskey.close
set rskey=nothing
next
rs.movenext
next
end if
rs.close 
conn.close
set conn=nothing
response.Write("success1~~~")
%>


这是一段asp的代码,实现的功能是把TE_CorpInfo的CI_Keywords字段的信息存放到一张新表SS的KeyName字段中去。因为CI_Keywords字段的组成是(a b c d)这种模式,要把CI_Keywords的内容以空格为分隔符,分别存入到SS的KeyName。因为TE_CorpInfo这张表的数据有4万多条,所以执行这段代码,会超过响应时间,虽然我设置了10分钟,后来我只能限制每次的数量为1000条,但是这样效率太低,而且执行速度还是不理想。所以,我想把上述代码改成 纯 SQL的代码,去服务器SQL端执行,但是SQL代码我不是很懂,不知道怎么写来实现这个功能,所以请教各位SQL大侠···

在线等···急急急···

92 个解决方案

#1



--这样?
insert tb2
select a+','+b+','+c+','+d from tb1

#2


偶看起来也晕,帮顶了.

#3


#4


insert into ss (KeyName)
select a+' '+b+' '+c
from TE_CorpInfo

#5


写个存储过程供后台调用,楼主最好给出表结构

#6


引用 1 楼 csdyyr 的回复:
SQL code
--这样?
insert tb2
select a+','+b+','+c+','+d from tb1

不是这样,要取的表是TE_CorpInfo,这张表有个CI_Keywords字段,字段的内容:sky blue water ,是这种形式存放的。现在要把TE_CorpInfo表的CI_Keywords字段内容以空格为间隔符,分别存放到SS表里去,同时要实现批量存放,因为TE_CorpInfo有4万多条的数据。
你可以看我的ASP代码,逻辑很清楚的,就是纯SQL代码我不会写。

(我的实现逻辑,就是先取TE_CorpInfo的CI_Keywords记录,以记录总数做个循环。然后在循环里,把CI_Keywords以空格为间隔拆分,作为一个数组,然后把数组的内容以维数为循环一一存入到SS表里面去)

期待好的解决方法···~~~

#7


拆分表:

--> --> (Roy)生成測試數據
 
if not object_id('Tab') is null
    drop table Tab
Go
Create table Tab([Col1] int,[COl2] nvarchar(5))
Insert Tab
select 1,N'a,b,c' union all
select 2,N'd,e' union all
select 3,N'f'
Go

SQL2000用辅助表:
if object_id('Tempdb..#Num') is not null
    drop table #Num
go
select top 100 ID=Identity(int,1,1) into #Num from syscolumns a,syscolumns b
Select 
    a.Col1,COl2=substring(a.Col2,b.ID,charindex(',',a.Col2+',',b.ID)-b.ID) 
from 
    Tab a,#Num b
where
    charindex(',',','+a.Col2,b.ID)=b.ID --也可用 substring(','+a.COl2,b.ID,1)=','


SQL2005用Xml:

select 
    a.COl1,b.Col2
from 
    (select Col1,COl2=convert(xml,'<root><v>'+replace(COl2,',','</v><v>')+'</v></root>') from Tab)a
outer apply
    (select Col2=C.v.value('.','nvarchar(100)') from a.COl2.nodes('/root/v')C(v))b




SQL05用CTE:

;with roy as 
(select Col1,COl2=cast(left(Col2,charindex(',',Col2+',')-1) as nvarchar(100)),Split=cast(stuff(COl2+',',1,charindex(',',Col2+','),'') as nvarchar(100)) from Tab
union all
select Col1,COl2=cast(left(Split,charindex(',',Split)-1) as nvarchar(100)),Split= cast(stuff(Split,1,charindex(',',Split),'') as nvarchar(100)) from Roy where split>''
)
select COl1,COl2 from roy order by COl1 option (MAXRECURSION 0)

生成结果:
/*
Col1        COl2
----------- -----
1           a
1           b
1           c
2           d
2           e
3           f
*/


#8


引用 4 楼 HEROWANG 的回复:
SQL codeinsert into ss (KeyName)
select a+' '+b+' '+c
from TE_CorpInfo


老大啊,不是a b c 字段,而是 TE_CorpInfo有个字段CI_Keywords的内容存放形式是 a b c 这种形式。我存放到SS表去,要把这个字段的a b c拆分为三个字段分别存入到SS。
-----------------------
我简化表描述:
假如存在a表3条数据
a表:

a.id   a.keyname
1      sky blue water 
2      book apple shirt 
3      cup yellow org

-----------------------
转到b表后,应该为
b表
b.id   b.keyname
1      sky  
2      blue
3      water
4      book
5      apple
6      shirt
7      cup
8      yellow
9      org

 

#9


参考:
if not object_id('Tab') is null
    drop table Tab
Go
Create table Tab([COl2] nvarchar(20))
Insert Tab
select N'sky blue water'
Go


if object_id('Tempdb..#Num') is not null
    drop table #Num
go
select top 100 ID=Identity(int,1,1) into #Num from syscolumns a,syscolumns b

Select 
    COl2=substring(replace(a.Col2, ' ', ','),b.ID,charindex(',',replace(a.Col2, ' ', ',')+',',b.ID)-b.ID) 
from 
    Tab a,#Num b
where
    charindex(',',','+replace(a.Col2, ' ', ','),b.ID)=b.ID 
/*
COl2
------------------------
sky
blue
water
*/

#10


引用 8 楼 limfungsuen 的回复:
引用 4 楼 HEROWANG 的回复:
SQL codeinsert into ss (KeyName)
select a+' '+b+' '+c
from TE_CorpInfo


老大啊,不是a b c 字段,而是 TE_CorpInfo有个字段CI_Keywords的内容存放形式是 a b c 这种形式。我存放到SS表去,要把这个字段的a b c拆分为三个字段分别存入到SS。
-----------------------
我简化表描述:
假如存在a表3条数据
a表:

a.id   a.keyname
1      sky blue water
2      book apple shirt


if not object_id('Tab') is null
    drop table Tab
Go
Create table Tab([COl1] int, [COl2] nvarchar(20))
Insert Tab
SELECT 1,  'sky blue water' UNION ALL 
SELECT 2,  'book apple shirt' UNION ALL 
SELECT 3,  'cup yellow org'
Go


if object_id('Tempdb..#Num') is not null
    drop table #Num
go
select top 100 ID=Identity(int,1,1) into #Num from syscolumns a,syscolumns b

Select id=identity(int,1,1) ,
    COl2=substring(replace(a.Col2, ' ', ','),b.ID,charindex(',',replace(a.Col2, ' ', ',')+',',b.ID)-b.ID)
  into #
from 
    Tab a,#Num b
where
    charindex(',',','+replace(a.Col2, ' ', ','),b.ID)=b.ID 

select * from #
drop table #
/*
id          COl2
----------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1           sky
2           blue
3           water
4           book
5           apple
6           shirt
7           cup
8           yellow
9           org

(9 row(s) affected)

*/

#11


引用 7 楼 csdyyr 的回复:
SQL code拆分表:

--> --> (Roy)生成測試數據
 
if not object_id('Tab') is null
    drop table Tab
Go
Create table Tab([Col1] int,[COl2] nvarchar(5))
Insert Tab
select 1,N'a,b,c' union all
select 2,N'd,e' union all
select 3,N'f'
Go

SQL2000用辅助表:
if object_id('Tempdb..#Num') is not null
    drop table #Num
go
select top 100 ID=Identity(int,1,1) into #Num from syscolumns a,sysco…


这位大侠,虽然我看到不是很懂,不过可以慢慢消化,但是您只是把数据给取出来了,我还要把这些数据一一存放到另外一张表段里面啊,接下去要怎么操作,好事总不能只做一半吧·····

#12


楼主还是要把基本的select,insert,update,事务弄明白,熟悉一点,对你写程序有很大帮助的,比如果你的问题,用asp要写十几行代码,执行效率还不高,换成sql就不一样了,不但只要一行,而且执行速度也是相当地快,是不是有事半功倍的效果呢

#13


引用 8 楼 limfungsuen 的回复:
引用 4 楼 HEROWANG 的回复:
SQL codeinsert into ss (KeyName)
select a+' '+b+' '+c
from TE_CorpInfo


老大啊,不是a b c 字段,而是 TE_CorpInfo有个字段CI_Keywords的内容存放形式是 a b c 这种形式。我存放到SS表去,要把这个字段的a b c拆分为三个字段分别存入到SS。
-----------------------
我简化表描述:
假如存在a表3条数据
a表:

a.id   a.keyname
1      sky blue water
2      book apple shirt

if not object_id('Tab') is null
    drop table Tab
Go
Create table Tab([COl1] int, [COl2] nvarchar(20))
Insert Tab
SELECT 1,  'sky blue water' UNION ALL 
SELECT 2,  'book apple shirt' UNION ALL 
SELECT 3,  'cup yellow org'
Go


if object_id('Tempdb..#Num') is not null
    drop table #Num
go
select top 100 ID=Identity(int,1,1) into #Num from syscolumns a,syscolumns b

Select id=identity(int,1,1) ,
    COl2=substring(replace(a.Col2, ' ', ','),b.ID,charindex(',',replace(a.Col2, ' ', ',')+',',b.ID)-b.ID)
  into #
from 
    Tab a,#Num b
where
    charindex(',',','+replace(a.Col2, ' ', ','),b.ID)=b.ID 
insert b  --如果b(id int, keyname varchar(20))表已经存在
select * from #
--如果b不存在
--select * into b from #

drop table #

#14


引用 10 楼 csdyyr 的回复:
if not object_id('Tab') is null
    drop table Tab
Go
Create table Tab([COl1] int, [COl2] nvarchar(20))
Insert Tab
SELECT 1,  'sky blue water' UNION ALL 
SELECT 2,  'book apple shirt' UNION ALL 
SELECT 3,  'cup yellow org'
Go


if object_id('Tempdb..#Num') is not null
    drop table #Num
go
select top 100 ID=Identity(int,1,1) into #Num from syscolumns a,syscolumns b

Select id=identity(int,1,1) ,
    COl2=substring(replace(a.Col2, ' ', ','),b.ID,charindex(',',replace(a.Col2, ' ', ',')+',',b.ID)-b.ID)
  into #
from 
    Tab a,#Num b
where
    charindex(',',','+replace(a.Col2, ' ', ','),b.ID)=b.ID 

select * from #
drop table #
/*
id          COl2
----------- 
1           sky
2           blue
3           water
4           book
5           apple
6           shirt
7           cup
8           yellow
9           org

(9 row(s) affected)

*/


大侠,BS我自己一下,看的似懂非懂
select top 100 ID=Identity(int,1,1) into #Num from syscolumns a,syscolumns b:意思是一次操作100条??
我要实现一次性操作4W数据呢?然后ID是不连续的····可能问的比较笨···主要我还是不会灵活改成自己可以用的

能否麻烦大侠帮我贴个我能直接用的,真是麻烦了··然后我把要用到的表结构和流程再描述一下(分不够,我可以加)

表:TE_CorpInfo   (有4W多条记录,ID并不连续)
字段:CI_ID   CI_Keywords
形式:10001   sky blue water 
     10002    book apple shirt 
     10005    cup yellow org  
     ......
     61245    box phone paper

说明:总共4W多条数据

表:SS (空表,用来接收TE_CorpInfo的CI_Keywords信息)
字  段:KeyID   KeyName
接收后:1      sky  
       2      blue 
       3      water 
       4      book 
       5      apple 
       6      shirt 
       7      cup 
       8      yellow 
       9      org 
       ........

说明:这数据取的形式已经前几贴说明。。。我最终最好实现,一次性,把TE_CorpInfo的CI_Keywords处理存入SS表



先谢过···大侠~~~~~~等待回答····




#15



Create table Tab(CI_ID int, CI_Keywords nvarchar(20))
Insert Tab
SELECT 10001,  'sky blue water' UNION ALL 
SELECT 10002,  'book apple shirt' UNION ALL 
SELECT 10005,  'cup yellow org' UNION ALL 
SELECT 61245,  'box phone paper'
Go
create table SSS(KeyID int,  KeyName varchar(20))
go

if object_id('Tempdb..#Num') is not null
    drop table #Num
go
select top 40000 ID=Identity(int,1,1) into #Num from syscolumns a,syscolumns b

Select id=identity(int,1,1) ,
    COl2=substring(replace(a.CI_Keywords, ' ', ','),b.ID,charindex(',',replace(a.CI_Keywords, ' ', ',')+',',b.ID)-b.ID)
  into #
from
    Tab a,#Num b
where
    charindex(',',','+replace(a.CI_Keywords, ' ', ','),b.ID)=b.ID

insert SSS  
select * from #

SELECT * FROM SSS

drop table Tab,SSS,# 
/*
KeyID       KeyName
----------- --------------------
1           sky
2           book
3           cup
4           box
5           blue
6           yellow
7           phone
8           apple
9           water
10          paper
11          shirt
12          org

(12 row(s) affected)
*/

#16



Tab=TE_CorpInfo
SSS=SS

#17


--修改排序
Create table Tab(CI_ID int, CI_Keywords nvarchar(20))
Insert Tab
SELECT 10001,  'sky blue water' UNION ALL 
SELECT 10002,  'book apple shirt' UNION ALL 
SELECT 10005,  'cup yellow org' UNION ALL 
SELECT 61245,  'box phone paper'
Go
create table SSS(KeyID int,  KeyName varchar(20))
go

if object_id('Tempdb..#Num') is not null
    drop table #Num
go
select top 40000 ID=Identity(int,1,1) into #Num from syscolumns a,syscolumns b

Select id=identity(int,1,1) ,
    COl2=substring(replace(a.CI_Keywords, ' ', ','),b.ID,charindex(',',replace(a.CI_Keywords, ' ', ',')+',',b.ID)-b.ID)
  into #
from
    Tab a,#Num b
where
    charindex(',',','+replace(a.CI_Keywords, ' ', ','),b.ID)=b.ID
order by CI_ID,b.id

insert SSS  
select id,col2 from # 

SELECT * FROM SSS

drop table Tab,SSS,# 
/*
KeyID       KeyName
----------- --------------------
1           sky
2           blue
3           water
4           book
5           apple
6           shirt
7           cup
8           yellow
9           org
10          box
11          phone
12          paper

(12 row(s) affected)
*/

#18


select top 100 ID=Identity(int,1,1) into #Num from syscolumns a,syscolumns b
CI_Keywords 包含的子字段数

#19


大侠,我照你的方式还是挂了,昨天在sql端运行了将近2个小时··导致SQL卡住了好像,后来其他同事反映了系统卡,没办法就取消了这个操作,结果变成了无用功··哎···

这个是我根据你给的,给看下是否有错·
create table SSS(KeyID int,  KeyName varchar(80))
go

if object_id('Tempdb..#Num') is not null
    drop table #Num
go
select top 40000 ID=Identity(int,1,1) into #Num from syscolumns a,syscolumns b

Select id=identity(int,1,1) ,
    COl2=substring(replace(a.CI_Keywords, ' ', ','),b.ID,charindex(',',replace(a.CI_Keywords, ' ', ',')+',',b.ID)-b.ID)
  into #
from
    TE_CorpInfo a,#Num b
where
    charindex(',',','+replace(a.CI_Keywords, ' ', ','),b.ID)=b.ID
order by CI_ID,b.id

insert SSS  
select id,col2 from # 

--SELECT * FROM SSS

drop table # 




引用 18 楼 ai_li7758521 的回复:
select top 100 ID=Identity(int,1,1) into #Num from syscolumns a,syscolumns b 
CI_Keywords 包含的子字段数
----什么意思?

#20


我先学VC了,再学VB了

#21


#22


bd

#23


学习

#24


有点难理解

#25


顶一下

#26


create table SS_tmp(CI_keywords varchar(200),col1 varchar(100),col2 varchar(100),col3 varchar(100));
insert into SS_tmp(CI_keywords) select CI_KeyWords from TE_CorpInfo where  ci_id > 13000 and ci_id<14000;
update SS_tmp set col1=substring(CI_keywords,0,instr(CI_keywords,' ')),CI_keywords=substring(CI_keywords,instr(CI_keywords,' '),length(CI_keywords));
update SS_tmp set col2=substring(CI_keywords,0,instr(CI_keywords,' ')),CI_keywords=substring(CI_keywords,instr(CI_keywords,' '),length(CI_keywords));
update SS_tmp set col3=substring(CI_keywords,0,instr(CI_keywords,' ')),CI_keywords=substring(CI_keywords,instr(CI_keywords,' '),length(CI_keywords));
insert into SS(col1,col2,col3) select col1,col2,col3 from SS_tmp;

#27


SS_tmp是临时表,col1,col2,col3是目标表的列名。替换成相应的列名就可以了。

#28


create table SS_tmp(CI_keywords varchar(200),col1 varchar(100),col2 varchar(100),col3 varchar(100));
insert into SS_tmp(CI_keywords) select CI_KeyWords from TE_CorpInfo where  ci_id > 13000 and ci_id<14000;
update SS_tmp set col1=substring(CI_keywords,0,charindex(CI_keywords,' ')),CI_keywords=substring(CI_keywords,charindex(CI_keywords,' '),len(CI_keywords));
update SS_tmp set col2=substring(CI_keywords,0,charindex(CI_keywords,' ')),CI_keywords=substring(CI_keywords,charindex(CI_keywords,' '),len(CI_keywords));
update SS_tmp set col3=substring(CI_keywords,0,charindex(CI_keywords,' ')),CI_keywords=substring(CI_keywords,charindex(CI_keywords,' '),len(CI_keywords));
insert into SS(col1,col2,col3) select col1,col2,col3 from SS_tmp;
用这个吧,刚才函数是oracle里面的。现在改成sql Server的了。

#29


该回复于2009-05-25 14:54:22被版主删除

#30


yun

#31


这是啥东东奥   

#32


告诉你一个绝招:
先将数据全部查询出来,然后导出成文本文件,再用sqlldr一次性导入,这个方法适合海量数据的导入,你4万数据就是小菜了。。。

#33


up

#34


我韩,,,是不是麻烦了点? 

#35


考虑用视图?

#36


我是进来学习的

#37


ding顶了!!!!

#38


引用 4 楼 HEROWANG 的回复:
SQL codeinsert into ss (KeyName)
select a+' '+b+' '+c
from TE_CorpInfo

``

#39


路過..學習..

#40


看的有点晕!

#41


SQL很不熟悉,但是楼主的意思应该是把 TE_CorpInfo 中在一行数据按空格拆分成多行然后存入到SS表中,这样用ASP的代码效率可能真的不是很高!

#42


学习一下……

#43


引用 28 楼 cnrefresh 的回复:
create table SS_tmp(CI_keywords varchar(200),col1 varchar(100),col2 varchar(100),col3 varchar(100)); 
insert into SS_tmp(CI_keywords) select CI_KeyWords from TE_CorpInfo where  ci_id > 13000 and ci_id <14000; 
update SS_tmp set col1=substring(CI_keywords,0,charindex(CI_keywords,' ')),CI_keywords=substring(CI_keywords,charindex(CI_keywords,' '),len(CI_keywords)); 
update SS_tmp set col2=substr…


这位大哥,理解错我的意思了
1、并不是每个CI_keywords 字段是三个词组成,可以是10个,8个,1个;形式就是以空格为间隔
2、存放到SS表,也不是对应几个字段,而是就一个字段,把CI_keywords以空格间隔取到的字符作为多个记录存放进去



引用 32 楼 bbqqqbq 的回复:
告诉你一个绝招: 
先将数据全部查询出来,然后导出成文本文件,再用sqlldr一次性导入,这个方法适合海量数据的导入,你4万数据就是小菜了。。。


刚一看这位大侠的话,我豁然开朗·但是马上我又萎靡了··你这里的 先将数据全部查询出来·其实这个查询是要处理的(不处理就等于没查),就是像上面描述的那样,4W条CI_keywords,通过空格拆分,可能是30W左右的数据··就这个操作··貌似会好久(但是我上司说SQL是百万级什么什么的,这点数据小意思,也补指导我,郁闷啊··),我用csdyyr 大侠的方法 就挂在那边了,不过没分开尝试。csdyyr 大侠的方法就是先处理存放到临时表,处理后再插入到SS表。

那天我运行了2个多小时,我也补清楚是执行到哪里了,其他同事提出系统卡,我就放弃了这个操作,晚点我再试试,或者··哪位大侠有更好的建议和方法?




#44


学习学习

#45


Create table Tab(CI_ID int, CI_Keywords nvarchar(20))
Insert Tab
SELECT 10001,  'sky blue water' UNION ALL 
SELECT 10002,  'book apple shirt' UNION ALL 
SELECT 10005,  'cup yellow org' UNION ALL 
SELECT 61245,  'box phone paper'
------生成测试数据
declare @i int

set @i = 1
while @i <=15
begin
insert into Tab select * from Tab
set @i = @i + 1
end
------
Go
create table SSS(KeyID int identity(1,1),  KeyName varchar(20))
go

SET STATISTICS TIME ON

insert INTO SSS(Keyname)
select
substring(replace(a.CI_Keywords,' ',','),b.Number,charindex(',',replace(a.CI_Keywords,' ',',')+',',b.Number)-b.Number) AS COLS
from Tab a,master..spt_values b
where b.Number between 1 and len(a.CI_Keywords) and b.type = 'P'
and charindex(',',','+replace(a.CI_Keywords,' ',','),b.Number) = b.Number
order by CI_ID

SET STATISTICS TIME OFF

select TOP 10 * from sss


/*
keyID  keyname
1 sky
2 blue
3 water
4 book
5 apple
6 shirt
7 cup
8 yellow
9 org
10 box
11 phone
12 paper
-----
SQL Server Execution Times:
   CPU time = 16250 ms,  elapsed time = 16331 ms.

(393216 行受影响)

(10 行受影响)
*/

俺修改一下,测试只需16s就OK啦

#46



Create table Tab(CI_ID int, CI_Keywords nvarchar(20))
Insert Tab
SELECT 10001,  'sky blue water' UNION ALL 
SELECT 10002,  'book apple shirt' UNION ALL 
SELECT 10005,  'cup yellow org' UNION ALL 
SELECT 61245,  'box phone paper'
------生成测试数据
declare @i int
set @i = 1
while @i <=15
begin
insert into Tab select * from Tab
set @i = @i + 1
end
------
Go
create table SSS(KeyID int identity(1,1),  KeyName varchar(20))
go

SET STATISTICS TIME ON

insert INTO SSS(Keyname)
select
substring(replace(a.CI_Keywords,' ',','),b.Number,charindex(',',replace(a.CI_Keywords,' ',',')+',',b.Number)-b.Number) AS COLS
from Tab a,master..spt_values b
where b.Number between 1 and len(a.CI_Keywords) and b.type = 'P'
and charindex(',',','+replace(a.CI_Keywords,' ',','),b.Number) = b.Number
order by CI_ID

SET STATISTICS TIME OFF

select TOP 10 * from sss


/*
keyID  keyname
1 sky
2 blue
3 water
4 book
5 apple
6 shirt
7 cup
8 yellow
9 org
10 box
11 phone
12 paper
-----
SQL Server Execution Times:
   CPU time = 16250 ms,  elapsed time = 16331 ms.

(393216 行受影响)

(10 行受影响)
*/

#47


--修改了一下,我试了6W多条数据十几秒,你可以把分拆和插入分开试看是哪里慢了:
--SS表用标识列,这样不必用临时表#
--不必用replace

Create table Tab(CI_ID int, CI_Keywords nvarchar(20))
Insert Tab
SELECT 10001,  'sky blue water' UNION ALL 
SELECT 10002,  'book apple shirt' UNION ALL 
SELECT 10005,  'cup yellow org' UNION ALL 
SELECT 61245,  'box phone paper'
Go

create table SSS(KeyID int identity(1,1),  KeyName varchar(20))
go

/*
declare @rowcount int
set @rowcount=4
WHILE @rowcount<40000
begin
  insert Tab
  select * from Tab
  set @rowcount=@rowcount+@@rowcount
end
*/
select top 40000 ID=Identity(int,1,1) into #Num from syscolumns a,syscolumns b

--insert SSS
Select COl2=substring(a.CI_Keywords, b.ID,charindex(' ',a.CI_Keywords+' ',b.ID)-b.ID)
from Tab a,#Num b
where ID<len(CI_Keywords) and charindex(' ', ' '+a.CI_Keywords, b.ID)=b.ID
--SELECT * FROM SSS

drop table Tab,#Num,SSS

#48


--还有这句有可以改进,根据你的数据,top 100够用了:
select top 100 ID=Identity(int,1,1) into #Num from syscolumns a,syscolumns b

#49


学习

#50


第一。你先把表里的数据全部导出来,不作处理。
第二。用sqlldr将数据导入你需要的表中。
注:sqlldr的控制插入语句中可以按照空格来拆分字符的,具体的插入的SQL写法可以搜索一下。
这个方法适合海量的数据导入,我以前用这个处理过亿数量级的数据,对你来说足够了。相关的资料可以网上找一下。

#1



--这样?
insert tb2
select a+','+b+','+c+','+d from tb1

#2


偶看起来也晕,帮顶了.

#3


#4


insert into ss (KeyName)
select a+' '+b+' '+c
from TE_CorpInfo

#5


写个存储过程供后台调用,楼主最好给出表结构

#6


引用 1 楼 csdyyr 的回复:
SQL code
--这样?
insert tb2
select a+','+b+','+c+','+d from tb1

不是这样,要取的表是TE_CorpInfo,这张表有个CI_Keywords字段,字段的内容:sky blue water ,是这种形式存放的。现在要把TE_CorpInfo表的CI_Keywords字段内容以空格为间隔符,分别存放到SS表里去,同时要实现批量存放,因为TE_CorpInfo有4万多条的数据。
你可以看我的ASP代码,逻辑很清楚的,就是纯SQL代码我不会写。

(我的实现逻辑,就是先取TE_CorpInfo的CI_Keywords记录,以记录总数做个循环。然后在循环里,把CI_Keywords以空格为间隔拆分,作为一个数组,然后把数组的内容以维数为循环一一存入到SS表里面去)

期待好的解决方法···~~~

#7


拆分表:

--> --> (Roy)生成測試數據
 
if not object_id('Tab') is null
    drop table Tab
Go
Create table Tab([Col1] int,[COl2] nvarchar(5))
Insert Tab
select 1,N'a,b,c' union all
select 2,N'd,e' union all
select 3,N'f'
Go

SQL2000用辅助表:
if object_id('Tempdb..#Num') is not null
    drop table #Num
go
select top 100 ID=Identity(int,1,1) into #Num from syscolumns a,syscolumns b
Select 
    a.Col1,COl2=substring(a.Col2,b.ID,charindex(',',a.Col2+',',b.ID)-b.ID) 
from 
    Tab a,#Num b
where
    charindex(',',','+a.Col2,b.ID)=b.ID --也可用 substring(','+a.COl2,b.ID,1)=','


SQL2005用Xml:

select 
    a.COl1,b.Col2
from 
    (select Col1,COl2=convert(xml,'<root><v>'+replace(COl2,',','</v><v>')+'</v></root>') from Tab)a
outer apply
    (select Col2=C.v.value('.','nvarchar(100)') from a.COl2.nodes('/root/v')C(v))b




SQL05用CTE:

;with roy as 
(select Col1,COl2=cast(left(Col2,charindex(',',Col2+',')-1) as nvarchar(100)),Split=cast(stuff(COl2+',',1,charindex(',',Col2+','),'') as nvarchar(100)) from Tab
union all
select Col1,COl2=cast(left(Split,charindex(',',Split)-1) as nvarchar(100)),Split= cast(stuff(Split,1,charindex(',',Split),'') as nvarchar(100)) from Roy where split>''
)
select COl1,COl2 from roy order by COl1 option (MAXRECURSION 0)

生成结果:
/*
Col1        COl2
----------- -----
1           a
1           b
1           c
2           d
2           e
3           f
*/


#8


引用 4 楼 HEROWANG 的回复:
SQL codeinsert into ss (KeyName)
select a+' '+b+' '+c
from TE_CorpInfo


老大啊,不是a b c 字段,而是 TE_CorpInfo有个字段CI_Keywords的内容存放形式是 a b c 这种形式。我存放到SS表去,要把这个字段的a b c拆分为三个字段分别存入到SS。
-----------------------
我简化表描述:
假如存在a表3条数据
a表:

a.id   a.keyname
1      sky blue water 
2      book apple shirt 
3      cup yellow org

-----------------------
转到b表后,应该为
b表
b.id   b.keyname
1      sky  
2      blue
3      water
4      book
5      apple
6      shirt
7      cup
8      yellow
9      org

 

#9


参考:
if not object_id('Tab') is null
    drop table Tab
Go
Create table Tab([COl2] nvarchar(20))
Insert Tab
select N'sky blue water'
Go


if object_id('Tempdb..#Num') is not null
    drop table #Num
go
select top 100 ID=Identity(int,1,1) into #Num from syscolumns a,syscolumns b

Select 
    COl2=substring(replace(a.Col2, ' ', ','),b.ID,charindex(',',replace(a.Col2, ' ', ',')+',',b.ID)-b.ID) 
from 
    Tab a,#Num b
where
    charindex(',',','+replace(a.Col2, ' ', ','),b.ID)=b.ID 
/*
COl2
------------------------
sky
blue
water
*/

#10


引用 8 楼 limfungsuen 的回复:
引用 4 楼 HEROWANG 的回复:
SQL codeinsert into ss (KeyName)
select a+' '+b+' '+c
from TE_CorpInfo


老大啊,不是a b c 字段,而是 TE_CorpInfo有个字段CI_Keywords的内容存放形式是 a b c 这种形式。我存放到SS表去,要把这个字段的a b c拆分为三个字段分别存入到SS。
-----------------------
我简化表描述:
假如存在a表3条数据
a表:

a.id   a.keyname
1      sky blue water
2      book apple shirt


if not object_id('Tab') is null
    drop table Tab
Go
Create table Tab([COl1] int, [COl2] nvarchar(20))
Insert Tab
SELECT 1,  'sky blue water' UNION ALL 
SELECT 2,  'book apple shirt' UNION ALL 
SELECT 3,  'cup yellow org'
Go


if object_id('Tempdb..#Num') is not null
    drop table #Num
go
select top 100 ID=Identity(int,1,1) into #Num from syscolumns a,syscolumns b

Select id=identity(int,1,1) ,
    COl2=substring(replace(a.Col2, ' ', ','),b.ID,charindex(',',replace(a.Col2, ' ', ',')+',',b.ID)-b.ID)
  into #
from 
    Tab a,#Num b
where
    charindex(',',','+replace(a.Col2, ' ', ','),b.ID)=b.ID 

select * from #
drop table #
/*
id          COl2
----------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1           sky
2           blue
3           water
4           book
5           apple
6           shirt
7           cup
8           yellow
9           org

(9 row(s) affected)

*/

#11


引用 7 楼 csdyyr 的回复:
SQL code拆分表:

--> --> (Roy)生成測試數據
 
if not object_id('Tab') is null
    drop table Tab
Go
Create table Tab([Col1] int,[COl2] nvarchar(5))
Insert Tab
select 1,N'a,b,c' union all
select 2,N'd,e' union all
select 3,N'f'
Go

SQL2000用辅助表:
if object_id('Tempdb..#Num') is not null
    drop table #Num
go
select top 100 ID=Identity(int,1,1) into #Num from syscolumns a,sysco…


这位大侠,虽然我看到不是很懂,不过可以慢慢消化,但是您只是把数据给取出来了,我还要把这些数据一一存放到另外一张表段里面啊,接下去要怎么操作,好事总不能只做一半吧·····

#12


楼主还是要把基本的select,insert,update,事务弄明白,熟悉一点,对你写程序有很大帮助的,比如果你的问题,用asp要写十几行代码,执行效率还不高,换成sql就不一样了,不但只要一行,而且执行速度也是相当地快,是不是有事半功倍的效果呢

#13


引用 8 楼 limfungsuen 的回复:
引用 4 楼 HEROWANG 的回复:
SQL codeinsert into ss (KeyName)
select a+' '+b+' '+c
from TE_CorpInfo


老大啊,不是a b c 字段,而是 TE_CorpInfo有个字段CI_Keywords的内容存放形式是 a b c 这种形式。我存放到SS表去,要把这个字段的a b c拆分为三个字段分别存入到SS。
-----------------------
我简化表描述:
假如存在a表3条数据
a表:

a.id   a.keyname
1      sky blue water
2      book apple shirt

if not object_id('Tab') is null
    drop table Tab
Go
Create table Tab([COl1] int, [COl2] nvarchar(20))
Insert Tab
SELECT 1,  'sky blue water' UNION ALL 
SELECT 2,  'book apple shirt' UNION ALL 
SELECT 3,  'cup yellow org'
Go


if object_id('Tempdb..#Num') is not null
    drop table #Num
go
select top 100 ID=Identity(int,1,1) into #Num from syscolumns a,syscolumns b

Select id=identity(int,1,1) ,
    COl2=substring(replace(a.Col2, ' ', ','),b.ID,charindex(',',replace(a.Col2, ' ', ',')+',',b.ID)-b.ID)
  into #
from 
    Tab a,#Num b
where
    charindex(',',','+replace(a.Col2, ' ', ','),b.ID)=b.ID 
insert b  --如果b(id int, keyname varchar(20))表已经存在
select * from #
--如果b不存在
--select * into b from #

drop table #

#14


引用 10 楼 csdyyr 的回复:
if not object_id('Tab') is null
    drop table Tab
Go
Create table Tab([COl1] int, [COl2] nvarchar(20))
Insert Tab
SELECT 1,  'sky blue water' UNION ALL 
SELECT 2,  'book apple shirt' UNION ALL 
SELECT 3,  'cup yellow org'
Go


if object_id('Tempdb..#Num') is not null
    drop table #Num
go
select top 100 ID=Identity(int,1,1) into #Num from syscolumns a,syscolumns b

Select id=identity(int,1,1) ,
    COl2=substring(replace(a.Col2, ' ', ','),b.ID,charindex(',',replace(a.Col2, ' ', ',')+',',b.ID)-b.ID)
  into #
from 
    Tab a,#Num b
where
    charindex(',',','+replace(a.Col2, ' ', ','),b.ID)=b.ID 

select * from #
drop table #
/*
id          COl2
----------- 
1           sky
2           blue
3           water
4           book
5           apple
6           shirt
7           cup
8           yellow
9           org

(9 row(s) affected)

*/


大侠,BS我自己一下,看的似懂非懂
select top 100 ID=Identity(int,1,1) into #Num from syscolumns a,syscolumns b:意思是一次操作100条??
我要实现一次性操作4W数据呢?然后ID是不连续的····可能问的比较笨···主要我还是不会灵活改成自己可以用的

能否麻烦大侠帮我贴个我能直接用的,真是麻烦了··然后我把要用到的表结构和流程再描述一下(分不够,我可以加)

表:TE_CorpInfo   (有4W多条记录,ID并不连续)
字段:CI_ID   CI_Keywords
形式:10001   sky blue water 
     10002    book apple shirt 
     10005    cup yellow org  
     ......
     61245    box phone paper

说明:总共4W多条数据

表:SS (空表,用来接收TE_CorpInfo的CI_Keywords信息)
字  段:KeyID   KeyName
接收后:1      sky  
       2      blue 
       3      water 
       4      book 
       5      apple 
       6      shirt 
       7      cup 
       8      yellow 
       9      org 
       ........

说明:这数据取的形式已经前几贴说明。。。我最终最好实现,一次性,把TE_CorpInfo的CI_Keywords处理存入SS表



先谢过···大侠~~~~~~等待回答····




#15



Create table Tab(CI_ID int, CI_Keywords nvarchar(20))
Insert Tab
SELECT 10001,  'sky blue water' UNION ALL 
SELECT 10002,  'book apple shirt' UNION ALL 
SELECT 10005,  'cup yellow org' UNION ALL 
SELECT 61245,  'box phone paper'
Go
create table SSS(KeyID int,  KeyName varchar(20))
go

if object_id('Tempdb..#Num') is not null
    drop table #Num
go
select top 40000 ID=Identity(int,1,1) into #Num from syscolumns a,syscolumns b

Select id=identity(int,1,1) ,
    COl2=substring(replace(a.CI_Keywords, ' ', ','),b.ID,charindex(',',replace(a.CI_Keywords, ' ', ',')+',',b.ID)-b.ID)
  into #
from
    Tab a,#Num b
where
    charindex(',',','+replace(a.CI_Keywords, ' ', ','),b.ID)=b.ID

insert SSS  
select * from #

SELECT * FROM SSS

drop table Tab,SSS,# 
/*
KeyID       KeyName
----------- --------------------
1           sky
2           book
3           cup
4           box
5           blue
6           yellow
7           phone
8           apple
9           water
10          paper
11          shirt
12          org

(12 row(s) affected)
*/

#16



Tab=TE_CorpInfo
SSS=SS

#17


--修改排序
Create table Tab(CI_ID int, CI_Keywords nvarchar(20))
Insert Tab
SELECT 10001,  'sky blue water' UNION ALL 
SELECT 10002,  'book apple shirt' UNION ALL 
SELECT 10005,  'cup yellow org' UNION ALL 
SELECT 61245,  'box phone paper'
Go
create table SSS(KeyID int,  KeyName varchar(20))
go

if object_id('Tempdb..#Num') is not null
    drop table #Num
go
select top 40000 ID=Identity(int,1,1) into #Num from syscolumns a,syscolumns b

Select id=identity(int,1,1) ,
    COl2=substring(replace(a.CI_Keywords, ' ', ','),b.ID,charindex(',',replace(a.CI_Keywords, ' ', ',')+',',b.ID)-b.ID)
  into #
from
    Tab a,#Num b
where
    charindex(',',','+replace(a.CI_Keywords, ' ', ','),b.ID)=b.ID
order by CI_ID,b.id

insert SSS  
select id,col2 from # 

SELECT * FROM SSS

drop table Tab,SSS,# 
/*
KeyID       KeyName
----------- --------------------
1           sky
2           blue
3           water
4           book
5           apple
6           shirt
7           cup
8           yellow
9           org
10          box
11          phone
12          paper

(12 row(s) affected)
*/

#18


select top 100 ID=Identity(int,1,1) into #Num from syscolumns a,syscolumns b
CI_Keywords 包含的子字段数

#19


大侠,我照你的方式还是挂了,昨天在sql端运行了将近2个小时··导致SQL卡住了好像,后来其他同事反映了系统卡,没办法就取消了这个操作,结果变成了无用功··哎···

这个是我根据你给的,给看下是否有错·
create table SSS(KeyID int,  KeyName varchar(80))
go

if object_id('Tempdb..#Num') is not null
    drop table #Num
go
select top 40000 ID=Identity(int,1,1) into #Num from syscolumns a,syscolumns b

Select id=identity(int,1,1) ,
    COl2=substring(replace(a.CI_Keywords, ' ', ','),b.ID,charindex(',',replace(a.CI_Keywords, ' ', ',')+',',b.ID)-b.ID)
  into #
from
    TE_CorpInfo a,#Num b
where
    charindex(',',','+replace(a.CI_Keywords, ' ', ','),b.ID)=b.ID
order by CI_ID,b.id

insert SSS  
select id,col2 from # 

--SELECT * FROM SSS

drop table # 




引用 18 楼 ai_li7758521 的回复:
select top 100 ID=Identity(int,1,1) into #Num from syscolumns a,syscolumns b 
CI_Keywords 包含的子字段数
----什么意思?

#20


我先学VC了,再学VB了

#21


#22


bd

#23


学习

#24


有点难理解

#25


顶一下

#26


create table SS_tmp(CI_keywords varchar(200),col1 varchar(100),col2 varchar(100),col3 varchar(100));
insert into SS_tmp(CI_keywords) select CI_KeyWords from TE_CorpInfo where  ci_id > 13000 and ci_id<14000;
update SS_tmp set col1=substring(CI_keywords,0,instr(CI_keywords,' ')),CI_keywords=substring(CI_keywords,instr(CI_keywords,' '),length(CI_keywords));
update SS_tmp set col2=substring(CI_keywords,0,instr(CI_keywords,' ')),CI_keywords=substring(CI_keywords,instr(CI_keywords,' '),length(CI_keywords));
update SS_tmp set col3=substring(CI_keywords,0,instr(CI_keywords,' ')),CI_keywords=substring(CI_keywords,instr(CI_keywords,' '),length(CI_keywords));
insert into SS(col1,col2,col3) select col1,col2,col3 from SS_tmp;

#27


SS_tmp是临时表,col1,col2,col3是目标表的列名。替换成相应的列名就可以了。

#28


create table SS_tmp(CI_keywords varchar(200),col1 varchar(100),col2 varchar(100),col3 varchar(100));
insert into SS_tmp(CI_keywords) select CI_KeyWords from TE_CorpInfo where  ci_id > 13000 and ci_id<14000;
update SS_tmp set col1=substring(CI_keywords,0,charindex(CI_keywords,' ')),CI_keywords=substring(CI_keywords,charindex(CI_keywords,' '),len(CI_keywords));
update SS_tmp set col2=substring(CI_keywords,0,charindex(CI_keywords,' ')),CI_keywords=substring(CI_keywords,charindex(CI_keywords,' '),len(CI_keywords));
update SS_tmp set col3=substring(CI_keywords,0,charindex(CI_keywords,' ')),CI_keywords=substring(CI_keywords,charindex(CI_keywords,' '),len(CI_keywords));
insert into SS(col1,col2,col3) select col1,col2,col3 from SS_tmp;
用这个吧,刚才函数是oracle里面的。现在改成sql Server的了。

#29


该回复于2009-05-25 14:54:22被版主删除

#30


yun

#31


这是啥东东奥   

#32


告诉你一个绝招:
先将数据全部查询出来,然后导出成文本文件,再用sqlldr一次性导入,这个方法适合海量数据的导入,你4万数据就是小菜了。。。

#33


up

#34


我韩,,,是不是麻烦了点? 

#35


考虑用视图?

#36


我是进来学习的

#37


ding顶了!!!!

#38


引用 4 楼 HEROWANG 的回复:
SQL codeinsert into ss (KeyName)
select a+' '+b+' '+c
from TE_CorpInfo

``

#39


路過..學習..

#40


看的有点晕!

#41


SQL很不熟悉,但是楼主的意思应该是把 TE_CorpInfo 中在一行数据按空格拆分成多行然后存入到SS表中,这样用ASP的代码效率可能真的不是很高!

#42


学习一下……

#43


引用 28 楼 cnrefresh 的回复:
create table SS_tmp(CI_keywords varchar(200),col1 varchar(100),col2 varchar(100),col3 varchar(100)); 
insert into SS_tmp(CI_keywords) select CI_KeyWords from TE_CorpInfo where  ci_id > 13000 and ci_id <14000; 
update SS_tmp set col1=substring(CI_keywords,0,charindex(CI_keywords,' ')),CI_keywords=substring(CI_keywords,charindex(CI_keywords,' '),len(CI_keywords)); 
update SS_tmp set col2=substr…


这位大哥,理解错我的意思了
1、并不是每个CI_keywords 字段是三个词组成,可以是10个,8个,1个;形式就是以空格为间隔
2、存放到SS表,也不是对应几个字段,而是就一个字段,把CI_keywords以空格间隔取到的字符作为多个记录存放进去



引用 32 楼 bbqqqbq 的回复:
告诉你一个绝招: 
先将数据全部查询出来,然后导出成文本文件,再用sqlldr一次性导入,这个方法适合海量数据的导入,你4万数据就是小菜了。。。


刚一看这位大侠的话,我豁然开朗·但是马上我又萎靡了··你这里的 先将数据全部查询出来·其实这个查询是要处理的(不处理就等于没查),就是像上面描述的那样,4W条CI_keywords,通过空格拆分,可能是30W左右的数据··就这个操作··貌似会好久(但是我上司说SQL是百万级什么什么的,这点数据小意思,也补指导我,郁闷啊··),我用csdyyr 大侠的方法 就挂在那边了,不过没分开尝试。csdyyr 大侠的方法就是先处理存放到临时表,处理后再插入到SS表。

那天我运行了2个多小时,我也补清楚是执行到哪里了,其他同事提出系统卡,我就放弃了这个操作,晚点我再试试,或者··哪位大侠有更好的建议和方法?




#44


学习学习

#45


Create table Tab(CI_ID int, CI_Keywords nvarchar(20))
Insert Tab
SELECT 10001,  'sky blue water' UNION ALL 
SELECT 10002,  'book apple shirt' UNION ALL 
SELECT 10005,  'cup yellow org' UNION ALL 
SELECT 61245,  'box phone paper'
------生成测试数据
declare @i int

set @i = 1
while @i <=15
begin
insert into Tab select * from Tab
set @i = @i + 1
end
------
Go
create table SSS(KeyID int identity(1,1),  KeyName varchar(20))
go

SET STATISTICS TIME ON

insert INTO SSS(Keyname)
select
substring(replace(a.CI_Keywords,' ',','),b.Number,charindex(',',replace(a.CI_Keywords,' ',',')+',',b.Number)-b.Number) AS COLS
from Tab a,master..spt_values b
where b.Number between 1 and len(a.CI_Keywords) and b.type = 'P'
and charindex(',',','+replace(a.CI_Keywords,' ',','),b.Number) = b.Number
order by CI_ID

SET STATISTICS TIME OFF

select TOP 10 * from sss


/*
keyID  keyname
1 sky
2 blue
3 water
4 book
5 apple
6 shirt
7 cup
8 yellow
9 org
10 box
11 phone
12 paper
-----
SQL Server Execution Times:
   CPU time = 16250 ms,  elapsed time = 16331 ms.

(393216 行受影响)

(10 行受影响)
*/

俺修改一下,测试只需16s就OK啦

#46



Create table Tab(CI_ID int, CI_Keywords nvarchar(20))
Insert Tab
SELECT 10001,  'sky blue water' UNION ALL 
SELECT 10002,  'book apple shirt' UNION ALL 
SELECT 10005,  'cup yellow org' UNION ALL 
SELECT 61245,  'box phone paper'
------生成测试数据
declare @i int
set @i = 1
while @i <=15
begin
insert into Tab select * from Tab
set @i = @i + 1
end
------
Go
create table SSS(KeyID int identity(1,1),  KeyName varchar(20))
go

SET STATISTICS TIME ON

insert INTO SSS(Keyname)
select
substring(replace(a.CI_Keywords,' ',','),b.Number,charindex(',',replace(a.CI_Keywords,' ',',')+',',b.Number)-b.Number) AS COLS
from Tab a,master..spt_values b
where b.Number between 1 and len(a.CI_Keywords) and b.type = 'P'
and charindex(',',','+replace(a.CI_Keywords,' ',','),b.Number) = b.Number
order by CI_ID

SET STATISTICS TIME OFF

select TOP 10 * from sss


/*
keyID  keyname
1 sky
2 blue
3 water
4 book
5 apple
6 shirt
7 cup
8 yellow
9 org
10 box
11 phone
12 paper
-----
SQL Server Execution Times:
   CPU time = 16250 ms,  elapsed time = 16331 ms.

(393216 行受影响)

(10 行受影响)
*/

#47


--修改了一下,我试了6W多条数据十几秒,你可以把分拆和插入分开试看是哪里慢了:
--SS表用标识列,这样不必用临时表#
--不必用replace

Create table Tab(CI_ID int, CI_Keywords nvarchar(20))
Insert Tab
SELECT 10001,  'sky blue water' UNION ALL 
SELECT 10002,  'book apple shirt' UNION ALL 
SELECT 10005,  'cup yellow org' UNION ALL 
SELECT 61245,  'box phone paper'
Go

create table SSS(KeyID int identity(1,1),  KeyName varchar(20))
go

/*
declare @rowcount int
set @rowcount=4
WHILE @rowcount<40000
begin
  insert Tab
  select * from Tab
  set @rowcount=@rowcount+@@rowcount
end
*/
select top 40000 ID=Identity(int,1,1) into #Num from syscolumns a,syscolumns b

--insert SSS
Select COl2=substring(a.CI_Keywords, b.ID,charindex(' ',a.CI_Keywords+' ',b.ID)-b.ID)
from Tab a,#Num b
where ID<len(CI_Keywords) and charindex(' ', ' '+a.CI_Keywords, b.ID)=b.ID
--SELECT * FROM SSS

drop table Tab,#Num,SSS

#48


--还有这句有可以改进,根据你的数据,top 100够用了:
select top 100 ID=Identity(int,1,1) into #Num from syscolumns a,syscolumns b

#49


学习

#50


第一。你先把表里的数据全部导出来,不作处理。
第二。用sqlldr将数据导入你需要的表中。
注:sqlldr的控制插入语句中可以按照空格来拆分字符的,具体的插入的SQL写法可以搜索一下。
这个方法适合海量的数据导入,我以前用这个处理过亿数量级的数据,对你来说足够了。相关的资料可以网上找一下。