Implementation of deleting duplicate data in DB2

Source: Internet
Author: User

The operations that we often use to delete duplicate data in DB2. The following describes how to delete duplicate data in DB2, hoping to help you learn how to delete duplicate data in DB2.

Use ROW_NUMBER to delete duplicate data
If the table TAB contains columns a, B, and c, you can use the following statements to delete duplicate rows that are the same for a, B, and c.

 
 
  1. delete from (select * from (select a,b,c,row_number() over(partition by a,b,c order by a,b,c) as row_num from tab) as e where row_num >1) 

If the data volume is too large, use the following method:

 
 
  1. Create table emp_profile_temp like emp_profile; 

Large data volumes use LOAD FROM CURSUR

 
 
  1. DECLARE mycursor CURSOR FOR SELECT distinct * FROM emp_profile;  
  2. LOAD FROM mycursor OF CURSOR INSERT INTO emp_profile_temp; 
 
 
  1. drop table emp_profile;  
  2. rename table emp_profile_temp to emp_profile  

DB2 common table expression usage

Cross-database access to DB2 tables

DB2 tablespace size limit

Lotus Notes calls the DB2 Stored Procedure

DB2 connection Server Configuration

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.