在创建表命令SQL上缺少正确的括号 [英] Missing right Paranthesis on Create Table command SQL

查看:87
本文介绍了在创建表命令SQL上缺少正确的括号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建下表时,出现错误消息

When creating the below tables I get the error message

ORA-00907:缺少右括号.

ORA-00907: missing right parenthesis.

create table CustomerOrder (
    CustomerOrderNumber NUMBER(15) CONSTRAINT Customer_Order_Number_pk PRIMARY KEY
    Customer_Number         NUMBER(7), CONSTRAINT Customer_Number_fk FOREIGN KEY,
    Order_Date              Date(6) CONSTRAINT Order_Date_not_null NOT NULL,
    Order_Status        VARCHAR2(20) CONSTRAINT Order_Status NOT NULL,
    Order_Total          NUMBER(20) CONSTRAINT Order_Total NOT NULL
);

客户编号错误:
ORA-00907:右括号缺失

ERROR at Customer_Number:
ORA-00907: missing right parenthesis

create table Work_Order (
    Work_Order_Number   NUMBER(20) CONSTRAINT Work_Order_Number_pk PRIMARY KEY,
    Product_Number      NUMBER(20),
    Work_Order_Date     Date(9) Work_Order_Date_not_null NOT NULL,
    Date_Required       Date(9) CONSTRAINT Date_Required_not_null NOT NULL,
    Date_Completed      Date(9) CONSTRAINT Date_Completed_not_null NOT NULL,
    Work_Status         VARCHAR2(100) CONSTRAINT Work_Status_not_null NOT NULL,
    Instruction         VARCHAR2(500) CONSTRAINT Instruction_not_null NOT NULL,
    CONSTRAINT Product_Number_fk FOREIGN KEY (Product_Number) REFERENCES Product(Product_Number)
);

Work_Order_Date发生错误:
ORA-00907:右括号缺失

ERROR at Work_Order_Date:
ORA-00907: missing right parenthesis

我试图通过在最后放置外键约束来解决此问题,但仍然无法正常工作.

I tried to fix it here by putting the constraint for foreign key at the end but still does not work.

create table Work_Order (
    Work_Order_Number   NUMBER(20) CONSTRAINT Work_Order_Number_pk PRIMARY KEY,
    Product_Number      NUMBER(20), CONSTRAINT Product_Number_fk FOREIGN KEY(Product_Number) REFERENCES Product(Product_Number),
    Work_Order_Date     Date(9) Work_Order_Date_not_null NOT NULL,
    Date_Required       Date(9) CONSTRAINT Date_Required_not_null NOT NULL,
    Date_Completed      Date(9) CONSTRAINT Date_Completed_not_null NOT NULL,
    Work_Status         VARCHAR2(100) CONSTRAINT Work_Status_not_null NOT NULL,
    Instruction         VARCHAR2(500) CONSTRAINT Instruction_not_null NOT NULL
);

Work_Order_Date发生错误:
ORA-00907:右括号缺失

ERROR at Work_Order_Date:
ORA-00907: missing right parenthesis

创建这些表需要进行哪些更改? 我需要在哪里添加括号?

What are the changes I need to make in order to create these tables? Where do I need to add the parenthesis?

这是有关珠宝店数据库的一门课程.这些表包含有关业务的信息.

This is for a piece of coursework about a jewellery shop database. The tables contain information about the business.

在SQL上运行时的预期结果:

Expected result when run on SQL:

表已创建

推荐答案

您似乎需要在列定义之后和CONSTRAINTS之前删除逗号,除非在末尾.应该是:

It looks like you need to remove commas after your column definitions and before CONSTRAINTS, unless it's at the end. it should be:

CustomerOrderNumber NUMBER(15) CONSTRAINT Customer_Order_Number_pk PRIMARY KEY Customer_Number NUMBER(7) CONSTRAINT

参考 https://www.techonthenet.com/oracle/tables/create_table. php

这篇关于在创建表命令SQL上缺少正确的括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆