SQL #1064 error but i can’t figure it out

huangapple go评论51阅读模式
英文:

SQL #1064 error but i can't figure it out

问题

>1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') NULL , cashExp VARCHAR(30) NOT NULL DEFAULT 'غير معروف' , `cashDa...' at line 1

this is an image of what i did

CREATE TABLE balancemapper.homedata (
cash DOUBLE(100000) NULL ,
cashExp VARCHAR(30) NOT NULL DEFAULT 'غير معروف' ,
cashDate DATE NOT NULL DEFAULT CURRENT_TIMESTAMP ,
cashComms VARCHAR(100) NOT NULL DEFAULT 'لا يوجد' ,
PRIMARY KEY (cash)
) ENGINE = InnoDB;

i can't figure it out i searched online but can't

i tried changing the default value from null to anything else and to none and null but no difference

i tried changing the date to varchar but nothing changed

i changed the length also nothing changed

英文:

>1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') NULL , cashExp VARCHAR(30) NOT NULL DEFAULT 'غير معروف' , `cashDa...' at line 1

this is an image of what i did

CREATE TABLE `balancemapper`.`homedata` (
    `cash` DOUBLE(100000) NULL , 
    `cashExp` VARCHAR(30) NOT NULL DEFAULT 'غير معروف' , 
    `cashDate` DATE NOT NULL DEFAULT CURRENT_TIMESTAMP , 
    `cashComms` VARCHAR(100) NOT NULL DEFAULT 'لا يوجد' , 
    PRIMARY KEY (`cash`)
) ENGINE = InnoDB;

i can't figure it out i searched online but can't

i tried changing the default value from null to anything else and to none and null but no difference

i tried changing the date to varchar but nothing changed

i changed teh length also nothing changed

答案1

得分: 1

FLOATDOUBLE 只接受两个参数或不接受参数。不能只提供一个参数。

MariaDB 不支持 100000 位数的精度。我记得限制是 255。

CREATE TABLE `balancemapper`.`homedata` (
    `cash` DOUBLE(100000,2) NULL
);

错误:cash 的显示宽度超出范围(最大为 255)。

此外,如果在 cash 列中存储货币值,不应该使用 FLOATDOUBLE。应该使用 DECIMAL 作为固定精度的缩放数据类型。

另请参考 https://mariadb.com/kb/en/double/

英文:

FLOAT and DOUBLE takes either two arguments or none. You can't give it a single argument.

MariaDB does not support a precision of 100000 digits. I recall the limit is 255.

CREATE TABLE `balancemapper`.`homedata` (
    `cash` DOUBLE(100000,2) NULL
);

Error: Display width out of range for 'cash' (max = 255)

Also if you are storing currency values in the cash column, you shouldn't use FLOAT or DOUBLE anyway. You should use DECIMAL for a fixed-precision scaled data type.

See also https://mariadb.com/kb/en/double/

huangapple
  • 本文由 发表于 2023年2月24日 02:19:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/75548809.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定