为什么这个 CREATE 命令没有运行?
这是脚本的一部分,整个脚本运行没有错误。我按照脚本进行了一些细微的更改,只是更改了名称等,并丢弃了一些命令,例如“创建或替换强制视图”、序列。
CREATE TABLE "EMPLOYEES"
("EMPLOYEE_ID" NUMBER(6,0),
"FIRST_NAME" VARCHAR2(20),
"LAST_NAME" VARCHAR2(25) CONSTRAINT "EMP_LAST_NAME_NN" NOT NULL ENABLE,
"EMAIL" VARCHAR2(25) CONSTRAINT "EMP_EMAIL_NN" NOT NULL ENABLE,
"PHONE_NUMBER" VARCHAR2(20),
"HIRE_DATE" DATE CONSTRAINT "EMP_HIRE_DATE_NN" NOT NULL ENABLE,
"JOB_ID" VARCHAR2(10) CONSTRAINT "EMP_JOB_NN" NOT NULL ENABLE,
"SALARY" NUMBER(8,2),
"COMMISSION_PCT" NUMBER(2,2),
"MANAGER_ID" NUMBER(6,0),
"DEPARTMENT_ID" NUMBER(4,0),
"BONUS" VARCHAR2(5),
CONSTRAINT "EMP_SALARY_MIN" CHECK (salary > 0) ENABLE,
CONSTRAINT "EMP_ID_PK" PRIMARY KEY ("EMPLOYEE_ID")
USING INDEX ENABLE,
CONSTRAINT "EMP_EMAIL_UK" UNIQUE ("EMAIL")
USING INDEX ENABLE
);
这是我从那里编辑的“CREATE TABLE”命令之一。
CREATE TABLE "PRODUCT"
("Prod_ID" VARCHAR2(10) CONSTRAINT "Prod_ID_NN" NOT NULL ENABLE,
"Prod_Price" NUMBER(3,2) CONSTRAINT "Prod_Price_NN" NOT NULL ENABLE,
"Prod_Avail" VARCHAR2(20) CONSTRAINT "Prod_Price_NN" NOT NULL ENABLE,
"Prod_MDate" DATE CONSTRAINT "Prod_MDate_NN" NOT NULL ENABLE,
"Prod_EDate" DATE CONSTRAINT "Prod_EDate_NN" NOT NULL ENABLE,
"Cust_ID" NUMBER(4,0),
"Sto_ID" VARCHAR(8) CONSTRAINT "Sto_ID_NN" NOT NULL ENABLE,
"Sup_ID" VARCHAR(10),
CONSTRAINT "Prod_ID_PK" PRIMARY KEY ("Prod_ID")
CONSTRAINT "Prod_Date_Interval" CHECK (Prod_EDate > Prod_MDate) ENABLE,
USING INDEX ENABLE
);
错误就出来了; ORA-00907:缺少右括号
ORA-06512:位于“SYS.WWV_DBMS_SQL_APEX_210200”,第 673 行
ORA-06512:位于“SYS.DBMS_SYS_SQL”,第 1658 行
ORA-06512:位于“SYS.WWV_DBMS_SQL_APEX_210200”,第 659 行
ORA-06512: 在“APEX_210200.WWV_FLOW_DYNAMIC_EXEC”,第 1829 行
“Prod_Avail”VARCHAR2(20) CONSTRAINT“Prod_Price_NN”NOT NULL ENABLE, “Prod_MDate”日期约束“Prod_MDate_NN”NOT NULL 启用, “Prod_EDate”日期约束“Prod_EDate_NN”非空启用,
“Cust_ID”NUMBER(4,0),
“Sto_ID”VARCHAR(8)约束“Sto_ID_NN”非空启用,
This is a part of a script which the whole script runs without errors. I followed the script and made minor changes, just by changing names, etc and discarded few commands like 'create or replace force view', sequences.
CREATE TABLE "EMPLOYEES"
("EMPLOYEE_ID" NUMBER(6,0),
"FIRST_NAME" VARCHAR2(20),
"LAST_NAME" VARCHAR2(25) CONSTRAINT "EMP_LAST_NAME_NN" NOT NULL ENABLE,
"EMAIL" VARCHAR2(25) CONSTRAINT "EMP_EMAIL_NN" NOT NULL ENABLE,
"PHONE_NUMBER" VARCHAR2(20),
"HIRE_DATE" DATE CONSTRAINT "EMP_HIRE_DATE_NN" NOT NULL ENABLE,
"JOB_ID" VARCHAR2(10) CONSTRAINT "EMP_JOB_NN" NOT NULL ENABLE,
"SALARY" NUMBER(8,2),
"COMMISSION_PCT" NUMBER(2,2),
"MANAGER_ID" NUMBER(6,0),
"DEPARTMENT_ID" NUMBER(4,0),
"BONUS" VARCHAR2(5),
CONSTRAINT "EMP_SALARY_MIN" CHECK (salary > 0) ENABLE,
CONSTRAINT "EMP_ID_PK" PRIMARY KEY ("EMPLOYEE_ID")
USING INDEX ENABLE,
CONSTRAINT "EMP_EMAIL_UK" UNIQUE ("EMAIL")
USING INDEX ENABLE
);
This is one of the 'CREATE TABLE' commands that I edited from there.
CREATE TABLE "PRODUCT"
("Prod_ID" VARCHAR2(10) CONSTRAINT "Prod_ID_NN" NOT NULL ENABLE,
"Prod_Price" NUMBER(3,2) CONSTRAINT "Prod_Price_NN" NOT NULL ENABLE,
"Prod_Avail" VARCHAR2(20) CONSTRAINT "Prod_Price_NN" NOT NULL ENABLE,
"Prod_MDate" DATE CONSTRAINT "Prod_MDate_NN" NOT NULL ENABLE,
"Prod_EDate" DATE CONSTRAINT "Prod_EDate_NN" NOT NULL ENABLE,
"Cust_ID" NUMBER(4,0),
"Sto_ID" VARCHAR(8) CONSTRAINT "Sto_ID_NN" NOT NULL ENABLE,
"Sup_ID" VARCHAR(10),
CONSTRAINT "Prod_ID_PK" PRIMARY KEY ("Prod_ID")
CONSTRAINT "Prod_Date_Interval" CHECK (Prod_EDate > Prod_MDate) ENABLE,
USING INDEX ENABLE
);
Errors came out;
ORA-00907: missing right parenthesis
ORA-06512: at "SYS.WWV_DBMS_SQL_APEX_210200", line 673
ORA-06512: at "SYS.DBMS_SYS_SQL", line 1658
ORA-06512: at "SYS.WWV_DBMS_SQL_APEX_210200", line 659
ORA-06512: at "APEX_210200.WWV_FLOW_DYNAMIC_EXEC", line 1829
"Prod_Avail" VARCHAR2(20) CONSTRAINT "Prod_Price_NN" NOT NULL ENABLE,
"Prod_MDate" DATE CONSTRAINT "Prod_MDate_NN" NOT NULL ENABLE,
"Prod_EDate" DATE CONSTRAINT "Prod_EDate_NN" NOT NULL ENABLE,
"Cust_ID" NUMBER(4,0),
"Sto_ID" VARCHAR(8) CONSTRAINT "Sto_ID_NN" NOT NULL ENABLE,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议您在使用 Oracle 时忘记双引号。他们没有什么好处,只有问题。
当您修复错误,
使用索引启用
,那么它有效:
但是 - 再一次 - 我不会就那样做。我该怎么做呢?像这样:
I'd suggest you to forget about double quotes while working with Oracle. Nothing good in them, only problems.
When you fix errors
using index enable
then it works:
But - once again - I wouldn't do it that way. How would I do it? Lke this: