Re: Re[2]: [SQL] Query to eliminate duplicates

Поиск
Список
Период
Сортировка
От Leslie Mikesell
Тема Re: Re[2]: [SQL] Query to eliminate duplicates
Дата
Msg-id 199812032002.OAA26371@Mercury.mcs.net
обсуждение исходный текст
Ответ на RE: Re[2]: [SQL] Query to eliminate duplicates  (Mario Filipe <mjnf@uevora.pt>)
Список pgsql-sql
According to Mario Filipe:
>
> >>> MF> Is there a way to eliminate duplicate records using just SQL?
> >>>
> >>> SELECT DISTINCT ...
> >
> >
> > MF>         The problem is that i have a table where there are duplicate
> > records
> > MF> and i want to delete them! I tryed creating a unique index but it told me
> > it
> > MF> couldn't because it didn't have a function to do something (I think it is
> > MF> because i had a boolean field in it)
>
> So a duplicate is actually a record that looks exactly like other record on the
> table...

How about:

select distinct * into newtable from oldtable ;
drop table oldtable;
alter table newtable rename to oldtable;

You have to drop/create indexes separately, even the ones built
implicitly from 'primary key' directives.

   Les Mikesell
    les@mcs.com

В списке pgsql-sql по дате отправления:

Предыдущее
От: Barracuda
Дата:
Сообщение: RE: Re[2]: [SQL] Please help: How to determine largest of two num bers in a query?
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: [SQL] Optimizations