Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Ustawienie SET DEFAULT przy tworzeniu klucza obcego
zimekk
post 17.12.2012, 11:57:35
Post #1





Grupa: Zarejestrowani
Postów: 70
Pomógł: 2
Dołączył: 25.11.2008

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


Mam dwie takie tablice:
  1. CREATE TABLE `category`
  2. (`id_category` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  3. `name` VARCHAR(255) NOT NULL
  4. )
  5. ENGINE = InnoDB;


  1. CREATE TABLE `product`
  2. (`id_product` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  3. `name` VARCHAR(255) NOT NULL,
  4. `describe` TEXT,
  5. `photo_url` VARCHAR(255),
  6. `price` FLOAT,
  7. `category_id` INT DEFAULT 6,
  8.  
  9. INDEX (`category_id`),
  10. CONSTRAINT `category_id_foreign` FOREIGN KEY (`category_id`)
  11. REFERENCES `category`(`id_category`) ON UPDATE CASCADE ON DELETE SET DEFAULT
  12. )
  13. ENGINE = InnoDB;


i wywala mi blad. Ale to oczywiste bo znalazlem taka informacje

Cytat
SET DEFAULT: This action is recognized by the parser, but InnoDB rejects table definitions containing ON DELETE SET DEFAULT or ON UPDATE SET DEFAULT clauses.


i tu moje pytanie. Jak moge to zrobic ze przy usuwaniu rekordu z `category` ustawia mi sie wartosc domyslna w `product`?


--------------------
Trochę historii...
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 1)
skowron-line
post 17.12.2012, 12:07:17
Post #2





Grupa: Zarejestrowani
Postów: 4 340
Pomógł: 542
Dołączył: 15.01.2006
Skąd: Olsztyn/Warszawa

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


Tylko trigger Ci zostaje


--------------------
I'm so fast that last night I turned off the light switch in my hotel room and was in bed before the room was dark - Muhammad Ali.
Peg jeżeli chcesz uprawiać sex to dzieci muszą wyjść, a jeżeli chcesz żeby był dobry ty też musisz wyjść - Al Bundy.

QueryBuilder, Mootools.net, bbcradio1::MistaJam
http://www.phpbench.com/
Go to the top of the page
+Quote Post

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 Wersja Lo-Fi Aktualny czas: 14.08.2025 - 13:36