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

执行CREATE TABLE脚本触发ORA-00907错误:缺少右括号问题求助

Alright, let's figure out why you're hitting that ORA-00907 "missing right parenthesis" error and fix your ATTRACTION_MH table script — it's a mix of simple typos and syntax gaps tripping up Oracle's parser.

Key Error Causes

  • Missing closing parenthesis (the immediate trigger for ORA-00907)
    Your script cuts off mid-definition at "AllocatedTime" NUMBER(3) NOTNULL ENABLE — there's no closing ) to wrap up all column definitions, nor a terminating ; to end the statement. This is the first thing Oracle flags.
  • Syntax typo: NOTNULL should be NOT NULL
    You merged the two keywords for the AllocatedTime column. Oracle requires a space between NOT and NULL to recognize the constraint correctly.
  • Non-standard VARCHAR usage
    You used VARCHAR(15) for the Category column. While Oracle treats VARCHAR as an alias for VARCHAR2, it's best practice to use VARCHAR2 consistently to avoid compatibility quirks.
  • Redundant NOT NULL on primary key column
    A PRIMARY KEY constraint already enforces NOT NULL, so including both on CityName is unnecessary (though not a breaking error).

Corrected Scripts

Here's the fixed, minimal version that will run without errors:

CREATE TABLE "ATTRACTION_MH"(
    "AttractionNo" NUMBER(11) NOT NULL ENABLE,
    "CityName" VARCHAR2(25) PRIMARY KEY ENABLE, -- PK implies NOT NULL, so we can omit that
    "AttractionName" VARCHAR2(25) NOT NULL ENABLE,
    "Category" VARCHAR2(15) NOT NULL ENABLE, -- Switched VARCHAR to VARCHAR2
    "AllocatedTime" NUMBER(3) NOT NULL ENABLE -- Fixed NOTNULL to NOT NULL
); -- Added closing parenthesis and terminating semicolon

If you prefer explicit constraint names (easier for debugging later), use this more maintainable version:

CREATE TABLE "ATTRACTION_MH"(
    "AttractionNo" NUMBER(11) NOT NULL ENABLE,
    "CityName" VARCHAR2(25) NOT NULL ENABLE,
    "AttractionName" VARCHAR2(25) NOT NULL ENABLE,
    "Category" VARCHAR2(15) NOT NULL ENABLE,
    "AllocatedTime" NUMBER(3) NOT NULL ENABLE,
    CONSTRAINT PK_ATTRACTION_MH_CITYNAME PRIMARY KEY ("CityName") ENABLE
);

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.22 08:15:13