Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: delete only 1 row

Re: delete only 1 row

From: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: 2000/05/30
Message-ID: <959718140.27543.0.pluto.d4ee154e@news.demon.nl>#1/1

A common trick is
delete from my_table x
where x.rowid = (select min(y.rowid)

                            from my_table y
                            where y.my_col = x.my_col)
and x.my_col = 3.

However, you should be aware every table should have a primary (and also unique) key, so you don't need to resort to this trick.

Hth,

Sybrand Bakker, Oracle DBA

EN <nlee_at_mediashell.net> schreef in berichtnieuws 3934217A.F2FEA841_at_mediashell.net...
> Hi,
>
> This is a newbie question ...
>
> For example, I'm executing the SQL statement below:
>
> DELETE FROM my_table WHERE my_col = 3
>
> My understanding is that every row with "my_col = 3" will be deleted.
> What if I only want one of those rows to be deleted?
>
>
> Any help is greatly appreciated,
> EN
Received on Tue May 30 2000 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US