You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PhpMyAdmin中SQL建表语句报错#1064,请求排查语法问题

解决MySQL CREATE TABLE时的#1064语法错误

Hey, I see where the problem is! That #1064 error is popping up because of how you defined the price column's data type.

MySQL requires that if you specify precision for the DOUBLE type, you need to provide two arguments: DOUBLE(M, D). Here's what those mean:

  • M: The total number of digits (both integer and fractional parts combined)
  • D: The number of digits after the decimal point

Your code uses DOUBLE(10) which only provides the first argument—this violates MySQL's syntax rules for the DOUBLE type, hence the error.

Fixes you can use:

  1. Skip precision specification entirely (let MySQL use default settings):
CREATE TABLE products( 
    id INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY, 
    title VARCHAR(255), 
    info TEXT, 
    price DOUBLE 
);
  1. Specify both total digits and decimal places (example: 10 total digits, 2 after decimal):
CREATE TABLE products( 
    id INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY, 
    title VARCHAR(255), 
    info TEXT, 
    price DOUBLE(10, 2) 
);

Quick side note:

If you're storing currency values (like product prices), I'd actually recommend using DECIMAL(M, D) instead of DOUBLE. Floating-point types like DOUBLE can have precision loss with decimal values, but DECIMAL stores exact numeric values—perfect for money-related data. For example:

price DECIMAL(10, 2)

内容的提问来源于stack exchange,提问作者Noname Noname

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 14:52:57