Delete duplicate fields

Dúvidas, dicas e truques de SQL, Select, Update, Delete, cláusulas, operações com joins, Funções em SQLs, etc
Post Reply
cleberzumba
Rank: DBA Júnior
Rank: DBA Júnior
Posts: 223
Joined: Thu, 14 Dec 2006 10:45 am
Location: Brasília-DF
Cleber Zumba de Souza

Personal as I do to delete the duplicate records getting only one, I delete a record and the copy is. Being that even the id are the same.
Dulima-SP
Rank: DBA Júnior
Rank: DBA Júnior
Posts: 193
Joined: Thu, 24 Jan 2008 1:56 pm
Location: SP
Dulima

DBA Oracle Jr

The ids do not have index unique ????

Do you have any unique key in the table ???
How did you duplicate these fields ??
cleberzumba
Rank: DBA Júnior
Rank: DBA Júnior
Posts: 223
Joined: Thu, 14 Dec 2006 10:45 am
Location: Brasília-DF
Cleber Zumba de Souza

It was not me who inserted, I already got it. There is nothing different, nothing at all.
gokden
Rank: DBA Pleno
Rank: DBA Pleno
Posts: 264
Joined: Sun, 19 Aug 2007 8:18 pm
Location: Ribeirão Preto - SP
Lucas de Souza

OCA Developer
Analista de sistemas

Dude, yes, yes ... pear a pouco qui já I'll show you how = D
cleberzumba
Rank: DBA Júnior
Rank: DBA Júnior
Posts: 223
Joined: Thu, 14 Dec 2006 10:45 am
Location: Brasília-DF
Cleber Zumba de Souza

Beauty, I'm waiting.



: -O
gokden
Rank: DBA Pleno
Rank: DBA Pleno
Posts: 264
Joined: Sun, 19 Aug 2007 8:18 pm
Location: Ribeirão Preto - SP
Lucas de Souza

OCA Developer
Analista de sistemas

Dude ... I liked this doubt and I was testing everything I knew and made this SQL Bloquinhu deletes the duplicate lines, oia chi legal ...

Select all

DECLARE 
   cursor c_1 is 
      select rowid 
           , row_number() OVER (Partition by numero order by numero) linha 
        from lucasq; 
BEGIN 
   for reg in c_1 
   loop 
      delete from lucasq where reg.linha > 1 and rowid = reg.rowid; 
   end loop; 
END;
Details From the LUCASQ table:

Select all

 
NUMERO                    LETRA 
-------------------- ---------- 
123                         123 
123                         123 
123                         123 
124                         124 
124                         124 
124                         124
cleberzumba
Rank: DBA Júnior
Rank: DBA Júnior
Posts: 223
Joined: Thu, 14 Dec 2006 10:45 am
Location: Brasília-DF
Cleber Zumba de Souza

Thanks my comrade, thanks.
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 6 guests