从一个db的一个表到另一个不同db的表中插入7900万条记录 [英] Insert 79 million records from one table of one db to another table of different db
问题描述
我在DB A上有一张表X,它有7900万条记录。
我想将这些记录传送到DB B表Y.
当我运行insert语句时,它失败了。此外,观察到CPU利用率很高。
如何使用SQL Server实现这一目标?
谢谢,
Lok。
我尝试了什么:
我试过插入选择,但它失败。
Hi,
I have a table X on DB A which has 79 million records.
I want to transfer these records to DB B table Y.
When I run the insert statement, it fails. Also it is observed that CPU utilization is high that time.
How can I achieve this using SQL Server?
Thanks,
Lok.
What I have tried:
I tried insert select but it fails.
推荐答案
7900万是相当多的。虽然你可以尝试以下事情 -
1.继续编写脚本(我认为,它仍然失败)
2.使用SELECT * INTO
声明
79 million is quite a amount. Though you can try following things-
1. Go with scripting (still I think, it'd fail)
2. Go withSELECT * INTO
statement
SELECT * INTO [db-name].new-table-name
FROM [db-name].table-name [WHERE condition]
您可以尝试一次插入几条记录并再次按照相同的步骤操作。我建议你使用 ROW_NUMBER [ ^ ]和 WHILE
循环让它开始。
我已经完成了大约83K的记录
KR
You can try to insert few records at a time and follow the same again. I'd suggest you to use ROW_NUMBER[^] and WHILE
loop to give it a go.
I have done with around 83K records
KR
这篇关于从一个db的一个表到另一个不同db的表中插入7900万条记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!