CREATE TABLE上的“缺少右括号”错误

时间:2019-03-21 01:06:57

标签: sql oracle

我是Oracle SQL的新手,并且在我们学习时学习它。我想知道我的SQL语句出了什么问题。我收到missing right parenthesis错误:

CREATE TABLE hotel(
    hotel_id                number(8)
                            NOT NULL
                            CONSTRAINT hotel_pk
                            PRIMARY KEY,

    user_id                 number(8)
                            NOT NULL,
                            CONSTRAINT user_fk FOREIGN KEY (user_id) REFERENCES users (user_id),

    hotel_name              varchar2(1024)
                            NOT NULL,

    creation_date           timestamp
                            NOT NULL
                            DEFAULT CURRENT_TIME
);

1 个答案:

答案 0 :(得分:1)

您还有一个逗号,请参见下面的评论:

CREATE TABLE hotel(
    hotel_id                number(8)
                            NOT NULL
                            CONSTRAINT hotel_pk
                            PRIMARY KEY,

    user_id                 number(8)
                            NOT NULL -- Comma was here
                            CONSTRAINT user_fk FOREIGN KEY (user_id) REFERENCES users (user_id),

    hotel_name              varchar2(1024)
                            NOT NULL,

    creation_date           timestamp
                            NOT NULL
                            DEFAULT CURRENT_TIME
);