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

如何修复使用指定长度int/integer时出现的ORA-00907缺失右括号错误

错误原因

Oracle数据库中,INT、INTEGER是NUMBER类型的内置别名,语法上不支持手动追加长度参数。你写的integer(50)、int(50)属于非法语法,导致SQL解析器无法识别,误判为括号提前闭合,最终抛出ORA-00907: missing right parenthesis错误。

解决方案

有两种可选方案,可根据你的实际需求选择:

  • 不需要限制整数位数的场景:直接删除int/integer后的长度参数即可,正确建表语句如下:
create table employees
(employee_number integer not null primary key,
last_name char(50) not null,
first_name char(50) not null,
Salary integer,
Dept_id integer);
  • 需要明确限制整数取值范围的场景:改用Oracle原生NUMBER类型指定精度,比如需要最多存50位整数就写NUMBER(50),示例语句如下:
create table employees
(employee_number NUMBER(50) not null primary key,
last_name char(50) not null,
first_name char(50) not null,
Salary NUMBER(20),
Dept_id integer);

补充说明:Oracle中未指定长度的int/integer默认等价于NUMBER(38),支持最大38位有效数字的整数存储,可覆盖绝大多数业务场景的使用需求,无特殊要求时直接使用即可。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.05 05:57:03