1

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

1064 - 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 4 行的“NOT NULL, mult smallint default NOT NULL, part_des varchar(120) NOT NULL defau”附近使用正确的语法

CREATE TABLE currentpricer_supplier1
(
    supplier_number varchar(50) NOT NULL,
    moq smallint default NOT NULL,
    mult smallint default NOT NULL,
    part_des varchar(120) default NOT NULL,
    uom_qbreak char(2) default NOT NULL,
    costbreak1 smallint default NOT NULL,
    costvalue1 dec(6,3) default NULL,
    costbreak2 smallint default NOT NULL,
    costvalue2 dec(6,3) default NULL,
    costbreak3 smallint default NOT NULL,
    costvalue3 dec(6,3) default NULL,
    costbreak4 smallint default NOT NULL,
    costvalue4 dec(6,3) default NULL,
    costbreak5 smallint default NOT NULL,
    costvalue5 dec(6,3) default NULL,
    costbreak6 smallint default NOT NULL,
    costvalue6 dec(6,3) default NULL,
    costbreak7 smallint default NOT NULL,
    costvalue7 dec(6,3) default NULL,
    costbreak8 smallint default NOT NULL,
    costvalue8 dec(6,3) default NULL,
    leadtime smallint default NOT NULL,
    leadtime_code char(2) default NOT NULL,
    PRIMARY KEY (supplier_number)
)
4

2 回答 2

2

如果您指定了默认关键字,则必须输入默认值。“not null”是另一种规范,而不是值本身。

默认值是多少?例如:

moq smallint 默认 0 NOT NULL,

于 2012-05-03T16:42:38.610 回答
1

在每个带有default关键字的列上,您没有提供默认值。这可以像0数字一样简单,默认值后面的字符为空字符串。此外,您的主键列不存在,因此您需要更正它 - 是 lumex_number 吗?

以下编辑有效:

CREATE TABLE currentpricer_supplier1
(
    lumex_number varchar(50) NOT NULL,
    moq smallint default 0 NOT NULL,
    mult smallint default 0 NOT NULL,
    part_des varchar(120) default 0 NOT NULL,
    uom_qbreak char(2) default 0 NOT NULL,
    costbreak1 smallint default 0 NOT NULL,
    costvalue1 dec(6,3) default 0 NULL,
    costbreak2 smallint default 0 NOT NULL,
    costvalue2 dec(6,3) default 0 NULL,
    costbreak3 smallint default 0 NOT NULL,
    costvalue3 dec(6,3) default 0 NULL,
    costbreak4 smallint default 0 NOT NULL,
    costvalue4 dec(6,3) default 0 NULL,
    costbreak5 smallint default 0 NOT NULL,
    costvalue5 dec(6,3) default 0 NULL,
    costbreak6 smallint default 0 NOT NULL,
    costvalue6 dec(6,3) default 0 NULL,
    costbreak7 smallint default 0 NOT NULL,
    costvalue7 dec(6,3) default 0 NULL,
    costbreak8 smallint default 0 NOT NULL,
    costvalue8 dec(6,3) default 0 NULL,
    leadtime smallint default 0 NOT NULL,
    leadtime_code char(2) default '' NOT NULL,
    PRIMARY KEY (lumex_number)
)
于 2012-05-03T16:46:07.527 回答