捌度空间导读:在对数据库进行操作过程中我们可能会遇到这种情况,表中的数据可能重复出现,使我们对数据库的操作过程 ...
在对数据库进行操作过程中我们可能会遇到这种情况,表中的数据可能重复出现,使我们对数据库的操作过程中带来很多的不便,那么怎么删除这些重复没有用的数据呢?一、删除部分字段重复数据
|
delete from 表名 a where a.rowid != ( select max(b.rowid) from 表名 b where a.字段1 = b.字段1 and a.字段2 = b.字段2 )
create table 临时表 as select a.字段1,a.字段2,MAX(a.ROWID) dataid from 正式表 a GROUP BY a.字段1,a.字段2; delete from 表名 a where a.rowid != ( select b.dataid from 临时表 b where a.字段1 = b.字段1 and a.字段2 = b.字段2 ); commit;
|
INSERT INTO t_table_bak select distinct * from t_table;
引用地址:
