Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Duplicate records???

Status
Not open for further replies.

ptillemans

Programmer
Aug 1, 2002
1
BE
Hi,

During an upgrade I came accross 2 (actually 4) records which I cannot distinguish, but which are duplicates.

tvl_test=# select namespace,id,max(oid),min(oid) from tvlprodcounter a group by namespace,id having count(*)>1;
namespace | id | max | min
-------------------------------------+--------------------+--------+--------
com.synegorie.adverts.ejb.AdvertCMP | etri_timesClicked | 238225 | 238225
com.synegorie.adverts.ejb.AdvertCMP | happy_timesClicked | 238364 | 238364
(2 rows)


Does anybody know how I can separate them and delete just 1 of the 2?

Thanks,

Peter



 
Hi ptillemans,

There is a special column in all postgres tables named OID. This is a number and is usually unique to each row in the table, except in very large tables the OID can wrap around and be reused. The following would display the OID in one of my tables:

select the_key, first, last, OID from testorders;

I would recommend that you have a serial field in every table that is assigns a unique key from an auto incrementing sequence. Look at the postgres doc to learn more about setting up a sequence.

Leland F. Jackson, CPA
Software - Master (TM)
Nothing Runs Like the Fox
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top