Delete duplicate records in tables without primary keys

Source: Internet
Author: User

Delete duplicate records in tables without primary keys

Create procedure delrepeat

As
Begin
SELECT distinct * INTO testTemp FROM test
Delete from test
Insert into test SELECT * FROM testTemp
Drop table testTemp
End

Distinct: used to remove duplicate items in a query

Begin ~ End range statement indicates the block used as the whole execution in the stored procedure.

Oracle database tutorial

Delete from a1 where rowid not in (select max (rowid) from a1 group by aa, bb, cc); -- it is processed by the rowid of the physical row number, which is very active and usable :)
Ern posts


Use a temporary table
 
Create table TMP_TABLE select distinct * FROM TABLE_NAME;
DROP TABLE_NAME;
Create table TABLE_NAME SELECT * FROM TMP_TABLE;
DROP TMP_TABLE;
COMMIT;

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.