0

I'm not very familiar with sql, so I'm using workbench to create a db. I keep getting this error:

Executing SQL script in server
ERROR: Error 1064: You have an error in your SQL syntax; check the 
manual that corresponds to your MySQL server version for the right 
syntax to use near ')
 REFERENCES `project2`.`REF` ()
 ON DELETE CASCADE
 ON UPDATE CASCADE' at line 6
SQL Code:
 CREATE TABLE IF NOT EXISTS `project2`.`REF_AUTH` (
 `REF#` INT(11) NOT NULL AUTO_INCREMENT,
 `RAUTHOR` VARCHAR(45) NOT NULL,
 PRIMARY KEY (`REF#`, `RAUTHOR`),
 CONSTRAINT `REF#`
 FOREIGN KEY ()
 REFERENCES `project2`.`REF` ()
 ON DELETE CASCADE
 ON UPDATE CASCADE)
 ENGINE = InnoDB
 DEFAULT CHARACTER SET = big5
SQL script execution finished: statements: 4 succeeded, 1 failed

Any help would be greatly appreciated.

asked Apr 7, 2018 at 17:02
0

1 Answer 1

0

Give this a try, your issue was the syntax with the foreign key and the references.

CREATE TABLE IF NOT EXISTS `project2`.`REF_AUTH` (
 `REF#` INT(11) NOT NULL AUTO_INCREMENT,
 `RAUTHOR` VARCHAR(45) NOT NULL,
 PRIMARY KEY (`REF#`, `RAUTHOR`),
 CONSTRAINT `REF#`
 FOREIGN KEY (`REF#`) REFERENCES `REF` (`REF#`) 
 ON DELETE CASCADE
 ON UPDATE CASCADE)
 ENGINE = InnoDB
 DEFAULT CHARACTER SET = big5

Syntax link

Another helpful link

answered Apr 7, 2018 at 17:28

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.