0

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

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
karramsos
  • 1
  • 3
  • I can't figure out where MariaDB differs from MySQL in creating tables, if they differ at all. - visible indexes don't exist in mariadb..ps there are other differences. If you are following a mysql tutorial I suggest you install mysql to avoid such. – P.Salmon Sep 22 '22 at 15:17

0 Answers0