當我插入多行到我的SQL Server 2008數據庫表中列示:單個INSERT INTO語句中允許有多少個值?
INSERT INTO MyTable (Name, ID)
VALUES ('First',1),
('Second',2),
('Third',3),
('Fourth',4),
('Fifth',5)
如何將這些價值觀的許多我會允許在單一INSERT INTO
語句中使用?
當我插入多行到我的SQL Server 2008數據庫表中列示:單個INSERT INTO語句中允許有多少個值?
INSERT INTO MyTable (Name, ID)
VALUES ('First',1),
('Second',2),
('Third',3),
('Fourth',4),
('Fifth',5)
如何將這些價值觀的許多我會允許在單一INSERT INTO
語句中使用?
根據我的測試,限制是1000行。只是試圖插入多行,並想出了這個錯誤:
The number of row value expressions in the INSERT statement exceeds the maximum allowed number of 1000 row values.
它實際上是記錄here:
The maximum number of rows that can be inserted in a single INSERT statement is 1000.
而且here:
The maximum number of rows that can be constructed by inserting rows directly in the VALUES list is 1000. Error 10738 is returned if the number of rows exceeds 1000 in that case.
注意的是,1000行限制爲僅對於單個VALUES
子句。正如評論說Lasse V. Karlsen:
It is not the
INSERT
statement that has a limit, it is theVALUES
clause. This is important if you do an insert that pulls data from somewhere. That insert is only limited by memory/transaction space/disk space.
我會說999 – lad2025
@ lad2025:你有什麼參考嗎? – c00000fd