SQL - Missing right parenthesis

前端 未结 4 693
耶瑟儿~
耶瑟儿~ 2021-01-06 00:39

I am trying to execute this script in Oracle 11g and getting the following error, I dont know where I am missing the paranthesis or what is the mistake kindly help me figure

4条回答
  •  清歌不尽
    2021-01-06 01:20

    Delete FOREIGN KEY clause. Rewrite your CREATE TABLE statement as follows:

    CREATE TABLE User_Role ( 
          user_role_id         INT  NOT NULL  , 
          Users_user_id        INT  REFERENCES Users(user_id), 
          User_Types_user_type VARCHAR(20) REFERENCES User_Types(user_type),  
          PRIMARY KEY(user_role_id) 
        )
    

    In this case constraint names will be generated by Oracle. If you want to give them more meaningful names you could write your create table statement as follows:

      CREATE TABLE User_Role1 ( 
          user_role_id         INT  NOT NULL  , 
          Users_user_id        INT  , 
          User_Types_user_type VARCHAR(20) ,  
          constraint PK_YourTable PRIMARY KEY(user_role_id), 
          constraint FK_Table_1 foreign key(Users_user_id) REFERENCES Users(user_id),
          constraint FK_Table_2 foreign key(User_Types_user_type) REFERENCES User_Types(user_type)
        )
    

提交回复
热议问题