Re: Re: pls Help us... (sql question)

From: "Richard Huxton" <dev(at)archonet(dot)com>
To: "Ross J(dot) Reedstrom" <reedstrm(at)rice(dot)edu>, "ibrahim cobanoglu" <icoban77(at)yahoo(dot)com>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Re: pls Help us... (sql question)
Date: 2001-07-03 16:19:13
Message-ID: 005201c103dc$0b82e260$1001a8c0@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

From: "Ross J. Reedstrom" <reedstrm(at)rice(dot)edu>

> Best to ask your questions on the list, so others may find them,
> with (hopefully) helpful answers in the archives in the future.
>
> so, you've got a table with indistinguishable rows. I'm afraid you've
> got to use an non ANSI extension. Every DB I've ever used has something
> equivelant. In PostgreSQL, it's the 'oid', so in your case, you'd do:
>
> SELECT oid,Name from tablename;
>
> and see something like:
> oid Name
> ------- -------
> 102453 ibrahim first row
> 102455 ibrahim second row
> 103756 ibrahim third row
>
>
> Then, you can delete, comparing on the oid:
>
> DELETE FROM tablename WHERE oid=102455;

Ibrahim - if you want to prevent any more duplicate entries you can make the
"name" column unique - see the CREATE TABLE docs but it would be something
like:

CREATE TABLE tablename (
"Name" varchar(64) UNIQUE;
);

Then PG will fail any attempt to insert a duplicate value (it is the same as
creating a UNIQUE index basically).

- Richard Huxton

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Martín Marqués 2001-07-03 16:27:15 Re: count(*)
Previous Message Martín Marqués 2001-07-03 16:17:49 Re: count(*)