理論小知識 刪除重複資料

2021-10-08 13:10:43 字數 433 閱讀 1408

如果你想刪除資料表中的重複資料,你可以使用以下的sql語句:

mysql> create table tmp select last_name, first_name, ***

-> from person_tbl;

-> group by (last_name, first_name, ***);

mysql> drop table person_tbl;

mysql> alter table tmp rename to person_tbl;

當然你也可以在資料表中新增 index(索引) 和 primay key(主鍵)這種簡單的方法來刪除表中的重覆記錄。方法如下:

mysql> alter ignore table person_tbl

-> add primary key (last_name, first_name);

刪除重複資料

介紹兩種刪除重複行的方式 1.使用臨時表,分組找出重複部分的id進行刪除 刪除table goods info 中存在重複goods id的記錄 select identity int,1,1 as autoid,into temptable from goods info select min a...

sql刪除重複資料

1 建立表 create table dbo test id numeric 18,0 identity 1,1 not null primary key,name varchar 200 collate chinese prc ci as null remark varchar 1024 coll...

mysql刪除重複資料

最近遇到刪除重複資料的問題,先分享一下解決辦法,如有不完善之處還望包涵!舉例如下 mysql select from table03 id name degree 1 fly 90 2 fly 90 3 fly 90 4 fly 80 5 wang 90 6 wang 90 7 wang 90 8 ...