Today I found a fairly simple problem I didn't know how to solve with PostgreSQL. I ended up with two rows in a table being exactly identical (all columns have the same value). Wanted to keep one of the two identical rows.

Could have deleted both and re-inserted one manually probably. But there's another way, using a "hidden" Postgres column: ctid.

stackoverflow.com/questions/65

Follow

@delroth Doesnt `DELETE .... LIMIT 1` also work?

@robryk I thought so, that's the first thing I tried, but apparently you can't LIMIT a DELETE with postgresql!

@delroth That's surprising. TIL. Does the error explain anything past the inability?

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.