Oracle 删除同名同身份证号的重复数据

Oracle 删除同名同身份证号的重复数据

        最近处理的系统中出现了大量重复数据,身份证号和姓名一样。而身份证号是作为用户登录系统的用户名,这样如果用户修改了密码,就有可能出现登录不了的情况。
        参阅了相关资料后,找到一种比较方便的删除重复数据的方法,记录如下(方便以后参考):
1 delete   from  t_test  where  rowid  not   in
2 ( select   max (t.rowid)  from  t_test t  group   by  name,cardid);


备份其它的语句:
根据身份证号码更新考生的性别信息:
update  t_examinee  set  eneesex = ' '   where  eneesex = ' X '   and  length(cardid) = 18   and  substr(cardid,  17 1 in  ( ' 1 ' , ' 3 ' , ' 5 ' , ' 7 ' , ' 9 ' )

update  t_examinee  set  eneesex = ' '   where  eneesex = ' X '   and  length(cardid) = 18   and  substr(cardid,  17 1 in  ( ' 0 ' , ' 2 ' , ' 4 ' , ' 6 ' , ' 8 ' )

update  t_examinee  set  eneesex = ' '   where  eneesex = ' X '   and  length(cardid) = 15   and  substr(cardid,  15 1 in  ( ' 1 ' , ' 3 ' , ' 5 ' , ' 7 ' , ' 9 ' )

update  t_examinee  set  eneesex = ' '   where  eneesex = ' X '   and  length(cardid) = 15   and  substr(cardid,  15 1 in  ( ' 0 ' , ' 2 ' , ' 4 ' , ' 6 ' , ' 8 ' )
更新人员的身份证号码信息:
update  t_mytable  set  cardid = substr(cardid, 0 , 17 ) || ' X '   where  cardid  like   ' %x '   and  cardtype = ' 居民身份证 '   and  length(cardid) = 18
使用A表的数据更新B表的对应数据:
update  t_e1  set  (inyear)  =  ( select  exyear  as  inyear 
from  t_tempyear  where  t_e1.eneeid = t_tempyear.eneeid) 
where   exists ( select   1   from  t_tempyear  where  t_tempyear.eneeid = t_e1.eneeid)


你可能感兴趣的:(Oracle 删除同名同身份证号的重复数据)