-1

创建表时遇到此错误。如何修复?

SQL查询:

CREATE TABLE Measurement(

MeasurementID NOT NULL ,
MeasurementTypeID INTEGER,
MeasurementNameCHAR( 100 ) ,
SemanticModelInfrastructureID INTEGER,
AddressCHAR( 150 ) ,
PRIMARY BOOL,
DerivedCalcCHAR( 255 ) ,
PRIMARY KEY ( MeasurementID ) ,
KEY ( MeasurementTypeID ) ,
KEY ( SemanticModelInfrastructureID )
);

MySQL 说:

#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 'NOT NULL,
    MeasurementTypeID INTEGER,
    MeasurementName CHAR(100),
    SemanticMo' at line 3 
4

3 回答 3

2

MeasurementID 没有类型;试试MeasurementID INTEGER NOT NULL

于 2013-06-18T20:41:04.017 回答
1

您在这里缺少数据类型:

MeasurementID NOT NULL

尝试:

MeasurementID INTEGER NOT NULL

NOT NULL 只是防止 NULL 值存储在列中的约束。您仍然需要声明所需的数据类型,如 INTEGER 或 CHAR。

于 2013-06-18T20:42:01.130 回答
1

有几个错误:

您需要在/声明MeasurementID之前给出数据类型nullnot null

MeasurementID int unsigned not null auto_increment,

您在CHAR几行之前缺少空格。

PRIMARY是保留字,需要用反引号括起来(就PRIMARY BOOL行了)

于 2013-06-18T20:43:55.533 回答