DB trigger to delete duplicate rows

I want to write a DB trigger. I dont have any exp with oracle.
I have two tables - profile and product
The issue I have is that for each row in table profile, there are atleast 4 identical rows in table product. I want to clean up table product so that for each profile there is only one product profile.
HOw to do this?
I want to have a DB trigger to check everytime theres an insert on table product...that is to delete duplicate rows.
Thanks in advance
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NievergeltSenior SW DevCommented:
Why do you not want to clean up your product table in one operation ?
Is there a reason you want to use a trigger ?
Vasi04Author Commented:
I want to use trigger to avoid future insert of duplicate rows. Is this spossible?
With Single operation I can get rid of already existing duplicate rows.

NievergeltSenior SW DevCommented:
You should be able to that with a trigger like the following:

  DELETE product WHERE <key conditions>

<key conditions> is the expression that define an "identical" entry where you reference values in the entry to be inserted with new (e.g. new.productId).

While this works, it is not a good idea, if you have many users working on the database.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial

The best way to do this is to create a Primary key on the product profile. If the table already has a product profile, then create a unique index on product profile. This will ensure that duplicates do not occur.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.