Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL]Nie można utworzyć FOREIGN KEY
miedziopl
post
Post #1





Grupa: Zarejestrowani
Postów: 18
Pomógł: 0
Dołączył: 2.03.2010

Ostrzeżenie: (0%)
-----


Witam

Mam problem nie mogę utworzyć relacji między dwoma tabelami próbuje dodać :
  1. ALTER TABLE zdjecia ADD FOREIGN KEY (id_Format) REFERENCES format(id_Format);
ale wyskakuje :

Cytat
#1452 - Cannot add or update a child row: a foreign key constraint fails (`fotograf`.<result 2 when explaining filename '#sql-b98_30e'>, CONSTRAINT `#sql-b98_30e_ibfk_1` FOREIGN KEY (`id_Format`) REFERENCES `format` (`id_Format`))


Szukałem w necie ale nie mogę znaleść błędu u siebie.
Tak wyglądają tabele

  1. CREATE TABLE zdjecia(
  2. id_Zdjecie int UNSIGNED AUTO_INCREMENT NOT NULL ,
  3. id_Format int UNSIGNED NOT NULL,
  4. Nazwa_zdjecie varchar(30),
  5. PRIMARY KEY (id_Zdjecie)
  6. );
  7. CREATE TABLE format(
  8. id_Format int UNSIGNED AUTO_INCREMENT NOT NULL,
  9. wymiar varchar(10),
  10. Rodzaj_papieru varchar(10),
  11. Cena Decimal(4,2),
  12. PRIMARY KEY (id_Format)
  13. );

Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 21.08.2025 - 03:27