我試圖在mysql中生成一個連續數字的大表。我只想要2列;一個主鍵和一個範圍爲0-X的數字列,其中X非常大。約。 64,000行應該這樣做。我試過這個代碼沒有成功:在mysql中創建一個「數字表」
CREATE TABLE numbers (
number INT NOT NULL
CONSTRAINT XPKnumbers
PRIMARY KEY CLUSTERED (number)
)
INSERT INTO numbers (number) VALUES (0)
DECLARE @i INT
SET @i = 20
WHILE 0 < @i
BEGIN
INSERT INTO numbers (number)
SELECT number + (SELECT 1 + Max(number) FROM numbers)
FROM numbers
SET @i = @i - 1
END
SELECT * FROM numbers
,我得到這個錯誤:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CONSTRAINT XPKnumbers PRIMARY KEY CLUSTERED (number)) INSERT INTO n' at line 3
任何人有任何建議,使這項工作?
添加的'插入「值」部分表(列)值(值) – 2012-03-17 15:50:25