Ver Mensaje Individual
  #1 (permalink)  
Antiguo 17/04/2013, 08:49
javiinet
 
Fecha de Ingreso: marzo-2012
Mensajes: 45
Antigüedad: 12 años, 1 mes
Puntos: 0
ERROR en Integridad referencial SET NULL

Hola.

¿Alguien entendido tendría a bien decirme porqué me dá el error
ERROR 1215 (HY000): Cannot add foreign key constraint

en las últimas constraints?

Si omito "on delete set null" si que funciona

Muchas gracias
Código MySQL:
Ver original
  1. CREATE TABLE PERSONA (
  2.     nif     varchar(10),
  3.     nombre  varchar(25),
  4.     constraint  PK_PERSONA primary key (nif));
  5.  
  6. CREATE TABLE  IMPUESTO (
  7.     cod     int(4),
  8.     nombre  varchar(20),
  9.     constraint  PK_IMPUESTO primary key (cod));
  10.  
  11. CREATE TABLE  PAGA (
  12.     nif     varchar(10),
  13.     cod     int(4),
  14.     constraint  PK_PAGA primary key (nif,cod),
  15.     constraint FK_TO_PERSONA  foreign key (nif)  references PERSONA (nif) on delete set null,
  16.     constraint FK_TO_IMPUESTO  foreign key (cod)  references IMPUESTO (cod) on delete set null);

Última edición por gnzsoloyo; 17/04/2013 a las 09:00 Razón: SQL Mal etiquetado