3

Operation failed: There was an error while applying the SQL script to the database.

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 ad_d19fb99c240e6c8.user () ON DELETE NO ACTION ON U' at line 10

SQL Statement:

CREATE TABLE `ad_d19fb99c240e6c8`.`instructor_profile` (
  `InstructorId` INT NULL,
  `InstructorName` VARCHAR(45) NULL,
  `companyId` INT NULL,
  `companyName` VARCHAR(45) NULL,
  `instructorEmail` VARCHAR(45) NULL,
  `ManagerName` VARCHAR(45) NULL,
  `ManagerEmail` VARCHAR(45) NULL,
  CONSTRAINT `UserId`
    FOREIGN KEY ()
    REFERENCES `ad_d19fb99c240e6c8`.`user` ()
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `VendorId`
    FOREIGN KEY ()
    REFERENCES `ad_d19fb99c240e6c8`.`vendor` ()
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
sagi
  • 40,026
  • 6
  • 59
  • 84
learning developer
  • 429
  • 2
  • 6
  • 10
  • 1
    To anyone finding this on Google: make sure your table engine matches, was an issue for this error in my case; see (and maybe upvote) here [*mysql Foreign key constraint is incorrectly formed error*](https://stackoverflow.com/questions/8434518/mysql-foreign-key-constraint-is-incorrectly-formed-error/34274215#34274215) – ᴍᴇʜᴏᴠ Mar 06 '21 at 19:55
  • 1
    @aexl Thank you, that was my issue, table engines weren't the same. – Uriahs Victor Apr 15 '21 at 17:17

6 Answers6

1

You're missing the column you want to reference and the column of the FK :

 CONSTRAINT `UserId`
      FOREIGN KEY (<TheColumn>)
      REFERENCES `ad_d19fb99c240e6c8`.`user` (<TheColumnInTheOtherTable>)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION,
 CONSTRAINT `VendorId`
      FOREIGN KEY (<TheSecondColumn>)
      REFERENCES `ad_d19fb99c240e6c8`.`vendor` (<TheSecondColumnInTheOtherTable>)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
sagi
  • 40,026
  • 6
  • 59
  • 84
1

You need to write name of the foreign key in parenthesis, yours are currently empty.

Shark4109
  • 71
  • 5
1

You must put a column name inside the parentheses, as others have said. This must match one of the column names previously given in your CREATE TABLE statement.

Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268
0

You haven´t set the columns on which you want to set the foreign keys!

 CONSTRAINT `UserId`
    FOREIGN KEY ( `#KEYCOLUMN#` )
    REFERENCES `ad_d19fb99c240e6c8`.`user` ( `#KEYCOLUMN#` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `VendorId`
    FOREIGN KEY ( `#KEYCOLUMN#` )
    REFERENCES `ad_d19fb99c240e6c8`.`vendor` ( `#KEYCOLUMN#` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
Pointi
  • 334
  • 3
  • 8
0

The operation failed: There was an error while applying the SQL script to the database.

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 ''UserId') REFERENCES ad_d19fb99c240e6c8.user () ON DELETE NO ACTION ' at line 10 SQL Statement: CREATE TABLE ad_d19fb99c240e6c8.instructor_profile ( InstructorId INT NOT NULL, InstructorName VARCHAR(45) NULL, companyId INT NULL,
companyName VARCHAR(45) NULL, ManagerName VARCHAR(45) NULL,
ManagerEmail VARCHAR(45) NULL, InstructorEmail VARCHAR(45) NULL, CONSTRAINT UserId FOREIGN KEY ('UserId') REFERENCES ad_d19fb99c240e6c8.user () ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT VendorId FOREIGN KEY ('VendorId') REFERENCES ad_d19fb99c240e6c8.vendor () ON DELETE NO ACTION ON UPDATE NO ACTION)

still the error exists

Pathik Vejani
  • 4,263
  • 8
  • 57
  • 98
learning developer
  • 429
  • 2
  • 6
  • 10
0

Because your new user doesn't have Privileges in MySQL Workbranch under User and Privileges tab Administrative Roles and Privileges give access to user

Mehdi
  • 11
  • 2