|
Publicité ' | |||||||||||||||||||||||
|
|
#1 |
|
Invité de passage
![]() Inscription : novembre 2006 Messages : 15 ![]() |
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; |
|
|
00
|
|
|
#2 | |
![]() ![]() ![]() Cédric DuprezInscription : avril 2002 Messages : 3 823 ![]() |
Citation:
ced |
|
|
|
00
|
|
|
#3 |
|
Invité de passage
![]() Inscription : novembre 2006 Messages : 15 ![]() |
j'ai essayé, ça ne fonctionne toujours pas :
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! |
|
|
00
|
|
|
#4 | |
|
Expert Confirmé Sénior
![]() ![]() Pierre Ingénieur qualité méthodes Inscription : mars 2003 Messages : 3 726 ![]() |
Citation:
__________________
"Il n'y a pas de bonnes réponses à une mauvaise question." (M. Godet) ----------------------- Pensez à cloturer votre sujet - Aucune réponse aux sollicitations techniques par MPUsus magister est optimus |
|
|
|
00
|
|
|
#5 |
|
Invité de passage
![]() Inscription : novembre 2006 Messages : 15 ![]() |
je suis d'accord avec ton tutoriel,
j'ai bien créer l'index (service_id) avant de référencer la clé étrangère dans la table categorie. Pour la colonne référencée, si j'ai bien compris les nombreux tutoriels lus, comme il s'agit d'une clé primaire(idservice), je n'ai pas besoin d'index. Toutes mes tables sont en InnoDB car mon fichier my.ini a été reconfiguré initialement. En fait si j'enlève uniquement la contrainte foreign key, la table se crée avec l'index. Pour les table précédentes ville et department j'ai effectué les mêmes opérations et ça fonctionne, c'est pour ça que je ne comprends pas. CREATE TABLE IF NOT EXISTS service ( idservice int(2) UNSIGNED ZEROFILL NOT NULL auto_increment, designationservice varchar(25) NOT NULL, PRIMARY KEY(idservice) )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, 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, index(service_id), PRIMARY KEY(idcategorie), FOREIGN KEY (service_id) REFERENCES service(idservice) )TYPE=InnoDB; |
|
|
00
|
|
|
#6 |
|
Membre habitué
![]() Inscription : mai 2006 Messages : 139 ![]() |
Le champ SERVICE.idservice est "UNSIGNED", alors que celui de la table catégorie n'a pas cette propriété.
En mettant la même configuration des deux côtés, ça fonctionne... |
|
|
00
|
|
|
#7 |
|
Invité de passage
![]() Inscription : novembre 2006 Messages : 15 ![]() |
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
|
|
|
00
|
|
|
#8 | |||||
|
Expert Confirmé Sénior
![]() ![]() Pierre Ingénieur qualité méthodes Inscription : mars 2003 Messages : 3 726 ![]() |
Citation:
Code :
Code :
__________________
"Il n'y a pas de bonnes réponses à une mauvaise question." (M. Godet) ----------------------- Pensez à cloturer votre sujet - Aucune réponse aux sollicitations techniques par MPUsus magister est optimus |
|||||
|
|
00
|
|
|
#9 |
|
Invité de passage
![]() Inscription : novembre 2006 Messages : 15 ![]() |
merci de ta réponse, je pensais que les propriétés communes obigatoires étaient la valeur, taille et propriété NOT NULL
|
|
|
00
|
Copyright © 2000-2012 - www.developpez.com