[Err] 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 'number primary key,

如题,mysql建表语句报错

  • 分析:就是一个语法错误,具体问题具体分析
  • 本例中,直接赋值过来的 sql建表语句,直接粘贴到mysql数据库运行,报错!
  • 经查询,mysql中 number类型的定义有如下选择:

Number 类型:

数据类型 描述

TINYINT(size) -128 到 127 常规。0 到 255 无符号。在括号中规定最大位数。

SMALLINT(size) -32768 到 32767 常规。0 到 65535 无符号。在括号中规定最大位数。

MEDIUMINT(size) -8388608 到 8388607 普通。0 to 16777215 无符号。在括号中规定最大位数。

INT(size) -2147483648 到 2147483647 常规。0 到 4294967295 无符号。在括号中规定最大位数。

BIGINT(size) -9223372036854775808 到 9223372036854775807 常规。0 到 18446744073709551615 无符号*。在括号中规定最大位数。

FLOAT(size,d) 带有浮动小数点的小数字。在括号中规定最大位数。在 d 参数中规定小数点右侧的最大位数。

DOUBLE(size,d) 带有浮动小数点的大数字。在括号中规定最大位数。在 d 参数中规定小数点右侧的最大位数。

DECIMAL(size,d) 作为字符串存储的 DOUBLE 类型,允许固定的小数点。

create table dept(
       deptno number(10) primary key,
       dname varchar2(30),
       loc varchar2(30)
)
  • 现sql
create table dept(
       deptno int(10) primary key,
       dname varchar(30),
       loc varchar(30)
)