1064-number not null default'0.0'附近的语法错误,

bpzcxfmw  于 2021-06-17  发布在  Mysql
关注(0)|答案(1)|浏览(295)

我无法使用下面的sql指令创建表
我试图修改一些默认值,但我有相同的错误。

DROP TABLE IF EXISTS CountryLanguage;
CREATE TABLE CountryLanguage (
  CountryCode TEXT NOT NULL DEFAULT '',
  Lang TEXT NOT NULL DEFAULT '',
  IsOfficial INTEGER NOT NULL DEFAULT '0',
  Percentage NUMBER NOT NULL default '0.0',
  PRIMARY KEY  (CountryCode,Lang)
);

表未创建,我收到以下消息:

Static analysis:

1 errors found during the scan.

Data type not recognized. (near "NUMBER" in position 164)

SQL request: CREATE TABLE CountryLanguage ( CountryCode TEXT NOT NULL DEFAULT '', Lang TEXT NOT NULL DEFAULT '', IsOfficial INTEGER NOT NULL DEFAULT '0', Percentage NUMBER NOT NULL default '0.0', PRIMARY KEY (CountryCode,Lang) )

MySQL replied: Documentation

# 1064 - Syntax error near 'NUMBER NOT NULL default' 0.0 ',

   PRIMARY KEY (CountryCode, Lang)
) 'at line 5
sczxawaw

sczxawaw1#

试试这个:

DROP TABLE IF EXISTS CountryLanguage;
CREATE TABLE CountryLanguage (
  CountryCode TEXT NOT NULL DEFAULT '',
  Lang TEXT NOT NULL DEFAULT '',
  IsOfficial INTEGER NOT NULL DEFAULT 0,
  Percentage FLOAT NOT NULL default 0.0,
  PRIMARY KEY  (CountryCode,Lang)
);

另外,注意常量数据-数字周围没有撇号(这是用于字符串的)

相关问题