Probléme création Table avec clef étrangère

Résolu/Fermé
jeremy9871 Messages postés 27 Date d'inscription jeudi 25 décembre 2008 Statut Membre Dernière intervention 19 mai 2011 - 17 mai 2010 à 09:14
 fiu - 17 mai 2010 à 11:11
Bonjour,

Quand je crée cette table tous ce passe bien :

CREATE TABLE informations (
Id int(10) unsigned NOT NULL AUTO_INCREMENT,
Id_Campagne int(10) unsigned NOT NULL,
Date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
MesurePression float unsigned NOT NULL,
MesureDebit float unsigned NOT NULL,
Mode tinyint(3) unsigned NOT NULL,
ConsigneDebit float unsigned NOT NULL,
ConsignePression float unsigned NOT NULL,
VitesseRotation float unsigned NOT NULL,
Frequence float unsigned NOT NULL,
Puissance float unsigned NOT NULL,
Tension float unsigned NOT NULL,
Courant float unsigned NOT NULL,
PRIMARY KEY (Id)
) ENGINE=InnoDB


Mais quand je crée celle ci un message d'erreur s'affiche

CREATE TABLE campagnes (
Id_informations int(10) unsigned NOT NULL,
Id int(10) unsigned NOT NULL AUTO_INCREMENT,
Nom char(20) NOT NULL,
INDEX inf_id (Id_informations),
FOREIGN KEY (Id_informations) REFERENCES informations(Id)
ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB

ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it
must be defined as a key

Merci de votre aide.

A voir également:

1 réponse

Salut,

Il va falloir te mettre à l'anglais. Le message d'erreur t'annonce que "tu ne peux avoir qu'une colonne auto-incrément et qu'elle doit être la clé"
0