MariaDB - Error Code: 1064 when creating a table

Viewed 24

I am trying to follow a MySQL tutorial and I am using MariaDB.

I am trying to create this table in database MyFirstDatabase:

This is the code to create the table:

CREATE TABLE `MyFirstDatabase`.`tblemployee` (
  `Employee_ID` INT NOT NULL AUTO_INCREMENT,
  `Employee_Name` VARCHAR(45) NOT NULL,
  `Employee_Department_ID` INT NOT NULL,
  `Employee_Grade_ID` INT NOT NULL DEFAULT 100,
  `Employee_Salary` INT NOT NULL,
  PRIMARY KEY (`Employee_ID`),
  INDEX `FK_Department_ID_idx` (`Employee_Department_ID` ASC) VISIBLE,
  CONSTRAINT `FK_Department_ID`
    FOREIGN KEY (`Employee_Department_ID`)
    REFERENCES `MyFirstDatabase`.`department` (`Department_ID`)
    ON DELETE RESTRICT
    ON UPDATE CASCADE);

The error message I am getting is:

Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' CONSTRAINT FK_Department_ID FOREIGN KEY (Employee_Department_ID) ...' at line 8

I can't figure out where MariaDB differs from MySQL in creating tables, if they differ at all.

Thanks for any help in advance.

Karramsos

0 Answers
Related