Bonjour à tous
je suis débutante en mysql et je voudrai ajouter des clés primaires provenant de 3 autres tables dans la table principale
En lisant sur le net j'ai lu que je devais utiliser
Alter table et add Foreign key
Le message retourné est le suivant :
#1072 - Key column 'idWin' doesn't exist in table
Mes tables sont les suivantes :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 ALTER TABLE contactme ADD FOREIGN KEY (idWin) REFERENCES win(idWin) , ADD FOREIGN KEY (id_VerOffice) REFERENCES veroffice(id_VerOffice) , ADD FOREIGN KEY (id_VIRUS) REFERENCES virus(id_VIRUS)
J'utilise xampp.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 CREATE TABLE IF NOT EXISTS `contactme` ( `id` int(11) NOT NULL AUTO_INCREMENT, `Nom` varchar(255) COLLATE latin1_general_ci NOT NULL, `Prenom` varchar(255) COLLATE latin1_general_ci NOT NULL, `email` varchar(255) COLLATE latin1_general_ci NOT NULL, `mobile` varchar(10) COLLATE latin1_general_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; CREATE TABLE IF NOT EXISTS `win` ( `idWin` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Clé primaire', `Nom_Win` varchar(255) DEFAULT NULL, PRIMARY KEY (`idWin`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; CREATE TABLE IF NOT EXISTS `virus` ( `id_VIRUS` int(11) NOT NULL AUTO_INCREMENT, `Nom_ANTIVIRUS` varchar(255) COLLATE latin1_general_ci DEFAULT NULL, PRIMARY KEY (`id_VIRUS`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; CREATE TABLE IF NOT EXISTS `veroffice` ( `id_VerOffice` int(11) NOT NULL AUTO_INCREMENT, `Nom_Office` varchar(255) COLLATE latin1_general_ci DEFAULT NULL, PRIMARY KEY (`id_VerOffice`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
Je ne comprend pas pourquoi la syntaxe me parait correcte
Pourriez vous m'expliquer ? Et me solutionner mon problème merci d'avance.
Partager