Evilripper Blog

A programmer's work is never done

  • Home
  • Downloads
  • News
  • Wallpapers
  • About Me

17

Oct

mySql DELETE ON CASCADE [myIsam]

Posted by evilripper  Published in database

MySql e’ leggero e velocissimo ma anche delle gran scomodita’: quella di non gestire le relationship e le references con l’engine MyIsam. Inoltre non si possono fare ne’ trigger(nelle versioni nuove si mi sa), ne’ transazioni! :-( Infatti se si ha l’esigenza di cancellare dei record relazionati a un’altra tabella in maniera automatica quando si elimina il record padre non lo si puo’ fare!
Fortunatamente dalla versione 4 o 3 non mi ricordo gestisce almento il delete multitabella quindi date 2 tabelle

tab1 (id,desc)

tab2(id,idfk,desc)

Se voglio cancellare in unica query un record tab1 e tutti i records che relazionati dentro tab2 non devo fare altro che lanciare questa query:

  1. DELETE tab1.*,tab2.* FROM tab1 LEFT JOIN tab2 ON  tab1.id=tab2.idfk WHERE tab1.id = 1

Uso il left join, perche’ presumo che se non ha figli non verrebbe cancellato, ma questa cosa non l’ho testata.

Un alternativa a questo abominio e’ quella di usare l’engine innoDb che a differenza del myIsam gestisce l’ ON DELETE CASCADE, ON UPDATE CASCADE e protegge i dati con l’integrita’ referenziale… tuttavia mySql diventa un po’ piu’ pesante e i servizi hosting non sempre danno la possibilita’ di utilizzare le innoDb.

Tags: mysql

no comment

Multilanguages

  • English
  • Italiano
Confronta i prezzi per Portatili!  Recensioni per Palmari
Le migliori recensioni: iPad PC Portatili Stampanti
Ricerca Prodotti:

Comparazione prezzi su Ciao
Ciao Box Generator

Affiliates & Sponsor

Add to Technorati Favorites

Paperblog

Il Bloggatore
Aggregatore di blog

Smilla Magazine


BlogItalia.it - La directory italiana dei blog

Tophost Hosting

8,890 spam comments
blocked by
Akismet

Locations of visitors to this page

My Flikr

Rock TotemRock TotemFiorenzuola di focaraSiroloSirolothe real oil priceEarly daysImprisonedTranquilitydawn

Social Connection







Blogroll

  • 2008computer
  • AumentaTrafficoWeb
  • Rocco Blog
  • jumping head shot
  • Libertà di scatto
  • Il blog di Paolo Ratto
  • il blog del picchio!
  • Skass Computer
  • The Developers
  • gyf.it
  • lu01 rock band
  • www.lugido.com
  • Michele Focchi
  • Michele Papaleo
  • Lo scannatoio
  • xoen->blog();

Categories

  • database (1)
  • development (17)
    • CSharp (4)
    • delphi (3)
    • javascript (1)
    • php (5)
    • vb.net (1)
  • facebook (1)
  • fotografia (1)
  • hacking (5)
  • hardware (19)
    • mobile (2)
  • internet (60)
    • cms (1)
    • google (12)
    • seo (1)
    • wordpress (4)
  • linux (6)
    • gentoo (4)
  • microsoft (5)
  • Senza categoria (5)
  • software (15)
  • videogames (7)
    • unreal tournament 3 (1)
  • winXp (2)

Archives

  • August 2010 (2)
  • July 2010 (2)
  • June 2010 (3)
  • May 2010 (14)
  • April 2010 (9)
  • March 2010 (6)
  • February 2010 (6)
  • January 2010 (6)
  • December 2009 (4)
  • November 2009 (1)
  • October 2009 (5)
  • September 2009 (3)
  • July 2009 (2)
  • May 2009 (1)
  • April 2009 (1)
  • March 2009 (2)
  • February 2009 (1)
  • January 2009 (2)
  • December 2008 (3)
  • November 2008 (4)
  • September 2008 (3)
  • June 2008 (3)
  • May 2008 (1)
  • April 2008 (1)
  • March 2008 (1)
  • February 2008 (4)
  • January 2008 (4)
  • December 2007 (2)
  • November 2007 (4)
  • October 2007 (7)
  • September 2007 (5)
  • August 2007 (2)
  • July 2007 (1)
  • June 2007 (2)

Recent Entries

  • How to Buy your First Digital Reflex
  • Skass computer a blog on information technology
  • Smallest PCs of the world
  • Spreaker Radio Web 2.0 On Air [Interview]
  • World Cup fifa 2010 live results on firefox
  • WinSxS The DLL Hell
  • Internet ip Addresses will run out in 18 months
  • Promotion hosting at 5.99 euros on tophost.it
  • NoFollow free Comments
  • The most visited places in the world

Recent Comments

  • Random Selection of Posts

    • Stranezze di Delphi
    • How to install WinXp from Usb
    • FileZilla Password Recovery
    • Google MyMaps Embedded
    • How To Write Bytes To File C#
    • Microsoft newsgroup goodbye
    • Un Portale dal Sapore di Vino
    • Call to undefined function: bcdiv()
    • Reiser guilty!
    • Classifica Miglior Antivirus Gratuiti e Freeware
© 2008 Evilripper Blog is proudly powered by WordPress
Theme designed by Roam2Rome