Re: Workbench export : constraints error
Here is the execution in Command Line of the code.
'Groupes' and 'CodePostaux' tables are well created..
i also tried to execute CREATE INDEX after the Table
but i got the same error during the creation of 'Famille' table,
because of constraints part (if i skip constraint declarations
it works properly..)
any idea ?
Thanks !
mysql> CREATE TABLE IF NOT EXISTS `SuperGESTION`.`Groupes` (
-> `idGroupes` SMALLINT NOT NULL AUTO_INCREMENT ,
-> `Nom` VARCHAR(32) NULL DEFAULT 'NC' ,
-> PRIMARY KEY (`idGroupes`) )
-> ENGINE = InnoDB;
Query OK, 0 rows affected (0.11 sec)
mysql>
mysql>
mysql> CREATE TABLE IF NOT EXISTS `SuperGESTION`.`CodePostaux` (
-> `idCP` MEDIUMINT UNSIGNED NOT NULL ,
-> `Ville` VARCHAR(32) NULL ,
-> `Ext` TINYINT UNSIGNED NULL DEFAULT 1 ,
-> PRIMARY KEY (`idCP`) )
-> ENGINE = InnoDB;
Query OK, 0 rows affected (0.06 sec)
mysql>
mysql>
mysql> CREATE TABLE IF NOT EXISTS `SuperGESTION`.`Famille` (
-> `idFamille` MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT ,
-> `idGroupes` SMALLINT NULL ,
-> `Adresse` VARCHAR(45) NULL DEFAULT 'NC' ,
-> `idCP` TINYINT UNSIGNED NULL ,
-> PRIMARY KEY (`idFamille`) ,
-> INDEX `GroupesLink` (`idGroupes` ASC) ,
-> INDEX `CPLink` (`idCP` ASC) ,
-> CONSTRAINT `GroupesLink`
-> FOREIGN KEY (`idGroupes` )
-> REFERENCES `SuperGESTION`.`Groupes` (`idGroupes` )
-> ON DELETE SET NULL
-> ON UPDATE CASCADE,
-> CONSTRAINT `CPLink`
-> FOREIGN KEY (`idCP` )
-> REFERENCES `SuperGESTION`.`CodePostaux` (`idCP` )
-> ON DELETE SET NULL
-> ON UPDATE CASCADE)
-> ENGINE = InnoDB; SHOW WARNINGS;
ERROR 1005 (HY000): Can't create table 'supergestion.famille' (errno: 150)
+-------+------+--------------------------------------------------------+
| Level | Code | Message |
+-------+------+--------------------------------------------------------+
| Error | 1005 | Can't create table 'supergestion.famille' (errno: 150) |
+-------+------+--------------------------------------------------------+
1 row in set (0.00 sec)