Re: Re: pls Help us... (sql question) - Mailing list pgsql-sql

From Richard Huxton
Subject Re: Re: pls Help us... (sql question)
Date
Msg-id 005201c103dc$0b82e260$1001a8c0@archonet.com
Whole thread Raw
In response to Re: pls Help us... (sql question)  ("Ross J. Reedstrom" <reedstrm@rice.edu>)
Responses While Using COPY COMMAND ...  (Bhuvan A <bhuvanbk@yahoo.com>)
List pgsql-sql
From: "Ross J. Reedstrom" <reedstrm@rice.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



pgsql-sql by date:

Previous
From: Gary Stainburn
Date:
Subject: Re: My First Function
Next
From: jim_esti@hotmail.com (Jim)
Date:
Subject: Text manipulation in SQL