首页 > 学技术 > 技术网文 > DB2 > 正文

[保留] 请问删掉相同的纪录,


来源 chinaunix.net 酷勤网整理

请问删掉相同的纪录
比如:

id , name
1,   name1
1,   name1

只保留一条记录!



 铁箭银枪 回复于:2003-12-10 10:35:48

导入一个临时表,删除后在导入原来的表
insert into tmptable select * from table1 group by id,name
delete from  table1
insert into table1 select * from tmptble


 welyngj 回复于:2003-12-10 13:16:03

1.CREATE TABLE t2 LIKE t1(这张表的名字)
2.INSERT INTO t2 SELECT DISTINCT * FROM t1
3.DROP TABLE t1
4.SELECT  *  FROM t2


 mymm 回复于:2003-12-11 10:46:47

TRY:
1、export to a.txt of del select * from t1
2、sort -u a.txt >; b.txt
3、import to t1 of del replace into t1




原文链接:http://bbs.chinaunix.net/viewthread.php?tid=219304
转载请注明作者名及原文出处



收藏本页到: