Amy 發問時間: 電腦與網際網路程式設計 · 1 0 年前

SQL語句錯誤訊息

想請問一下各位喔,

我現在在建table時遇到下列的錯誤訊息,

ORA-00907: missing right parenthesis

我把整個table的語句貼上來會比較清楚

SQL>

SQL> create table Book_Topic

2 (Topic varchar2(15),

3 Bookid varchar2(4),

4 constranit pkBook_Topic primary key (Topic),

5 constranit fkBook_Topic1 foreign key (Bookid) references book (Bookid));

constranit pkBook_Topic primary key (Topic),

*

ERROR at line 4:

ORA-00907: missing right parenthesis

SQL>

SQL> create table Book_Author

2 (Bookid varchar2(4),

3 Author varchar2(10),

4 constranit pkBook_Author primary key(Bookid),

5 constranit fkBook_Author1 foreign key (Bookid) references book (Bookid));

constranit pkBook_Author primary key(Bookid),

*

ERROR at line 4:

ORA-00907: missing right parenthesis

看起來像是少了右括號,但是我在設這個table的attribute還沒結束,照理來講應該結束時才放右括號

請問一下,是哪裡出現錯誤? 要怎麼修正呢?

謝謝!!

2 個解答

評分
  • 1 0 年前
    最佳解答

    其中一段,改這樣試試看

    create table Book_Topic (

    Topic varchar2(15),

    Bookid varchar2(4),

    constraint PK_Book_Topic primary key (Topic),

    constraint fk_Book_Topic1 foreign key (BOOKID) references book (BOOKID)

    );

    constraint 你打錯字了

    這是MS SQL上測的,我沒ORACLE環境,應該是一樣的

    參考資料: 自己
  • 1 0 年前

    @@" 我發現錯字了~~ 謝謝~~ :)

還有問題?馬上發問,尋求解答。