姬長信(Redy)

在MySQL中创建“数字表”


我正在尝试在MySQL中生成一个连续数字的大表.

我只想要2列;主键和数字列,范围为0-X,其中X非常大.约. 64,000行应该这样做.我试过这段代码没有成功:

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 

我收到此错误:

#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

有人建议让这项工作吗?