MySQL SQL Delete Notes MySQL SQL eliminare le note
To delete duplicates from a MySQL database table I normally copy the duplicate data first to a temporary table and then use the copied id’s to delete from the original table. Per eliminare i duplicati da un database MySQL tabella I normalmente copiare il duplicato dei dati prima di una tabella temporanea e quindi utilizzare il copiato id's per eliminare dalla tabella originale.
Delete using the temporary can take two forms. Eliminare utilizzando il temporaneo può assumere due forme. First is the slow way: Primo è la lentezza modo:
delete from target where id in (select id from temp); eliminare dal bersaglio in cui id (id selezionare da temp);
This can be agonizingly slow for a large table. Questo può essere agonizingly lento per un grande tavolo. A much faster option is: Una opzione molto più veloce è la seguente:
delete target from target, temp where target.id = temp.id; obiettivo di eliminare dal bersaglio, dove target.id temp = temp.id;
BTW: The copying into temporary table part is simple but not that simple. BTW: La copia tabella temporanea in parte è semplice ma non così semplice. Here’s what I do: Ecco quello che faccio:
insert into temp(id) select b.id from target a, target b where a.common_field1 = b.common_field1 and a.common_field2 = b.common_field2 … and a.id < b.id ; inserire in temp (id) selezionare b.id da bersaglio a, b dove bersaglio a.common_field1 = b.common_field1 e a.common_field2 = b.common_field2… e a.id <b.id;
Note: I am assuming all the tables have an unique row identifier (primary key). Nota: Io sono assumendo tutte le tabelle hanno un unico identificatore riga (chiave primaria).
Filed under Elencato sotto Database Banca dati , Headline News Headline News , How To Come , MySQL , Open Source Software Software open source , RDBMS | |
| |
RSS 2.0 RSS 2,0 | |
Trackback this Article | questo articolo |
Email this Article Invia questo articolo
You may also like to read Si può anche leggere come |




