Advertisement
jzgeorge

fk

Apr 11th, 2017
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --SELECT *
  2. DELETE
  3. FROM
  4.     esq_ceac_planclase.tbl_syllabus_bibliografias
  5. WHERE
  6.     NOT EXISTS(SELECT 1 FROM esq_ceac_planclase.tbl_syllabus WHERE esq_ceac_planclase.tbl_syllabus_bibliografias.id_syllabus= esq_ceac_planclase.tbl_syllabus.idregistro);
  7.  
  8. ALTER TABLE  esq_ceac_planclase.tbl_syllabus_bibliografias  
  9.      ADD CONSTRAINT fk_syllabus002 FOREIGN KEY (id_syllabus)
  10.           REFERENCES esq_ceac_planclase.tbl_syllabus (idregistro) ON DELETE CASCADE;
  11.  
  12. DELETE
  13. FROM
  14.     esq_ceac_planclase.tbl_syllabus_comentarios
  15. WHERE
  16.     NOT EXISTS(SELECT 1 FROM esq_ceac_planclase.tbl_syllabus WHERE esq_ceac_planclase.tbl_syllabus_comentarios.id_syllabus= esq_ceac_planclase.tbl_syllabus.idregistro);
  17.  
  18. ALTER TABLE  esq_ceac_planclase.tbl_syllabus_comentarios  
  19.      ADD CONSTRAINT fk_syllabus002 FOREIGN KEY (id_syllabus)
  20.           REFERENCES esq_ceac_planclase.tbl_syllabus (idregistro) ON DELETE CASCADE;
  21.  
  22.  
  23. DELETE
  24. FROM
  25.     esq_ceac_planclase.tbl_syllabus_cursos_paralelos
  26. WHERE
  27.     NOT EXISTS(SELECT 1 FROM esq_ceac_planclase.tbl_syllabus WHERE esq_ceac_planclase.tbl_syllabus_cursos_paralelos.id_syllabus= esq_ceac_planclase.tbl_syllabus.idregistro);
  28.  
  29. ALTER TABLE  esq_ceac_planclase.tbl_syllabus_cursos_paralelos  
  30.      ADD CONSTRAINT fk_syllabus002 FOREIGN KEY (id_syllabus)
  31.           REFERENCES esq_ceac_planclase.tbl_syllabus (idregistro) ON DELETE CASCADE;
  32.  
  33. DELETE
  34. FROM
  35.     esq_ceac_planclase.tbl_syllabus_mallas
  36. WHERE
  37.     NOT EXISTS(SELECT 1 FROM esq_ceac_planclase.tbl_syllabus WHERE esq_ceac_planclase.tbl_syllabus_mallas.id_syllabus= esq_ceac_planclase.tbl_syllabus.idregistro);
  38.  
  39. ALTER TABLE  esq_ceac_planclase.tbl_syllabus_mallas  
  40.      ADD CONSTRAINT fk_syllabus002 FOREIGN KEY (id_syllabus)
  41.           REFERENCES esq_ceac_planclase.tbl_syllabus (idregistro) ON DELETE CASCADE;
  42.  
  43. DELETE
  44. FROM
  45.     esq_ceac_planclase.tbl_syllabus_mu_departamentos
  46. WHERE
  47.     NOT EXISTS(SELECT 1 FROM esq_ceac_planclase.tbl_syllabus WHERE esq_ceac_planclase.tbl_syllabus_mu_departamentos.id_syllabus= esq_ceac_planclase.tbl_syllabus.idregistro);
  48.  
  49. ALTER TABLE  esq_ceac_planclase.tbl_syllabus_mu_departamentos  
  50.      ADD CONSTRAINT fk_syllabus002 FOREIGN KEY (id_syllabus)
  51.           REFERENCES esq_ceac_planclase.tbl_syllabus (idregistro) ON DELETE CASCADE;
  52.  
  53. DELETE
  54. FROM
  55.     esq_ceac_planclase.tbl_syllabus_objetivos
  56. WHERE
  57.     NOT EXISTS(SELECT 1 FROM esq_ceac_planclase.tbl_syllabus WHERE esq_ceac_planclase.tbl_syllabus_objetivos.id_syllabus= esq_ceac_planclase.tbl_syllabus.idregistro);
  58.  
  59. ALTER TABLE  esq_ceac_planclase.tbl_syllabus_objetivos  
  60.      ADD CONSTRAINT fk_syllabus002 FOREIGN KEY (id_syllabus)
  61.           REFERENCES esq_ceac_planclase.tbl_syllabus (idregistro) ON DELETE CASCADE;
  62.  
  63. DELETE
  64. FROM
  65.     esq_ceac_planclase.tbl_syllabus_temas
  66. WHERE
  67.     NOT EXISTS(SELECT 1 FROM esq_ceac_planclase.tbl_syllabus WHERE esq_ceac_planclase.tbl_syllabus_temas.id_syllabus= esq_ceac_planclase.tbl_syllabus.idregistro);
  68.  
  69. ALTER TABLE  esq_ceac_planclase.tbl_syllabus_temas  
  70.      ADD CONSTRAINT fk_syllabus002 FOREIGN KEY (id_syllabus)
  71.           REFERENCES esq_ceac_planclase.tbl_syllabus (idregistro) ON DELETE CASCADE;
  72.  
  73. DELETE
  74. FROM
  75.     esq_ceac_planclase.tbl_syllabus_temas_actividades
  76. WHERE
  77.     NOT EXISTS(SELECT 1 FROM esq_ceac_planclase.tbl_syllabus WHERE esq_ceac_planclase.tbl_syllabus_temas_actividades.id_syllabus= esq_ceac_planclase.tbl_syllabus.idregistro);
  78.  
  79. ALTER TABLE  esq_ceac_planclase.tbl_syllabus_temas_actividades  
  80.      ADD CONSTRAINT fk_syllabus002 FOREIGN KEY (id_syllabus)
  81.           REFERENCES esq_ceac_planclase.tbl_syllabus (idregistro) ON DELETE CASCADE;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement