problème concernant foreign key de type InnoDB
version mysql 4.1.9, phpMyAdmin 2.6.1
message d'erreur :
#1005 - Ne peut créer la table '.\alsaservice\categorie.frm' (Errcode: 150) ??
Toutes les tables sont en InnoDB
je m'aperçois que le message s'adresse surtout à la table categorie, car quand je la supprime je n'ai plus aucun problèmes. J'ai bien l'index, j'ai vérifié l'emplacement des tables
Où est le problème?:(
voici mes tables en fichier.txt :
CREATE TABLE IF NOT EXISTS userstype
(
iduserstype int(2) UNSIGNED ZEROFILL NOT NULL auto_increment,
denominationusers varchar(20) NOT NULL,
PRIMARY KEY(iduserstype)
)TYPE=InnoDB;
CREATE TABLE IF NOT EXISTS usersevaluation
(
idusersevaluation int(2) UNSIGNED ZEROFILL NOT NULL auto_increment,
note int(2) NOT NULL,
commentairenote varchar(30) NULL,
PRIMARY KEY(idusersevaluation)
)TYPE=InnoDB;
CREATE TABLE IF NOT EXISTS userslogin
(
iduserslogin int(8) UNSIGNED ZEROFILL NOT NULL auto_increment,
stringuserslog binary(8) NOT NULL,
PRIMARY KEY(iduserslogin)
)TYPE=InnoDB;
CREATE TABLE IF NOT EXISTS userspassword
(
iduserspassword int(8) UNSIGNED ZEROFILL NOT NULL auto_increment,
stringuserspassword binary(8) NOT NULL,
PRIMARY KEY(iduserspassword)
)TYPE=InnoDB;
CREATE TABLE IF NOT EXISTS service
(
idservice int(2) UNSIGNED NOT NULL,
designationservice varchar(25) NOT NULL,
PRIMARY KEY(idservice)
)TYPE=InnoDB;
CREATE TABLE IF NOT EXISTS modepaiement
(
idtypepaiement int(2) UNSIGNED ZEROFILL NOT NULL,
paiementcheque tinyint(1) NOT NULL,
paiementcarte tinyint(1) NOT NULL,
prelevement tinyint(1) NOT NULL,
PRIMARY KEY(idtypepaiement)
)TYPE=InnoDB;
CREATE TABLE IF NOT EXISTS prestation
(
idprestation int(2) UNSIGNED ZEROFILL NOT NULL,
designationprestation varchar(30) NOT NULL,
PRIMARY KEY(idprestation)
)TYPE=InnoDB;
CREATE TABLE IF NOT EXISTS department
(
iddepartment int(2) NOT NULL auto_increment,
namedepartment varchar(20) NOT NULL,
numberdepartment int(2) NOT NULL,
PRIMARY KEY(iddepartment)
)TYPE=InnoDB;
CREATE TABLE IF NOT EXISTS ville
(
idville int(6) UNSIGNED ZEROFILL NOT NULL auto_increment,
nameville varchar(30) NOT NULL,
cpville int(5) NOT NULL,
department_id int(2) NOT NULL default'',
index(department_id),
PRIMARY KEY(idville),
FOREIGN KEY (department_id) REFERENCES department(iddepartment) ON DELETE CASCADE
)TYPE=InnoDB;
CREATE TABLE IF NOT EXISTS categorie
(
idcategorie int(2) UNSIGNED ZEROFILL NOT NULL auto_increment,
namecategorie varchar(30) NOT NULL,
service_id int(2) NOT NULL default'',
index(service_id),
PRIMARY KEY(idcategorie),
FOREIGN KEY (service_id) REFERENCES service(idservice) ON DELETE CASCADE
)TYPE=InnoDB;:bug:
problème concernant foreign key de type InnoDB
j'ai essayé, ça ne fonctionne toujours pas ::oops:
CREATE TABLE IF NOT EXISTS categorie(
idcategorie int( 2 ) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT ,
namecategorie varchar( 30 ) NOT NULL ,
service_id int( 2 ) NOT NULL ,
INDEX ( service_id ) ,
PRIMARY KEY ( idcategorie ) ,
FOREIGN KEY ( service_id ) REFERENCES service( idservice )
) TYPE = InnoDB;
toujours la même erreur!
problème concernant foreign key de type InnoDB
concernant UNSIGNED ZEROFILL la table categorie autant que la table service possèdent cette propriété, c'est plutôt la table department qui n'est pas UNSIGNED mais cette table est référencée par la FOREIGN KEY de la table ville:roll:
problème concernant foreign key de type InnoDB
merci de ta réponse, je pensais que les propriétés communes obigatoires étaient la valeur, taille et propriété NOT NULL