Re: using limit with delete

Поиск
Список
Период
Сортировка
От Chris Smith
Тема Re: using limit with delete
Дата
Msg-id 425496CE.5070400@interspire.com
обсуждение исходный текст
Ответ на Re: using limit with delete  (Neil Conway <neilc@samurai.com>)
Ответы Re: using limit with delete
Список pgsql-general
I don't care about the order in my particular case, just that I have to
clear the table.

I'll try the subquery and see how I go :)

Thanks!

Neil Conway wrote:
> Chris Smith wrote:
>
>> I'm trying to use a limit clause with delete, but it doesn't work at
>> the moment
>
>
> It isn't in the SQL standard, and it would have undefined behavior: the
> sort order of a result set without ORDER BY is unspecified, so you would
> have no way to predict which rows DELETE would remove.
>
>> delete from table where x='1' limit 1000;
>
>
> You could use a subquery to achieve this:
>
> DELETE FROM table WHERE x IN
>     (SELECT x FROM table ... ORDER BY ... LIMIT ...);
>
> -Neil
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>    (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>

--
Regards,

Chris Smith

  Unit 2, 3 National Street, Rozelle, NSW 2039 Australia

Ph: +61 2 9555 5570
Fx: +61 2 9555 5571

email: info@interspire.com
web: http://www.interspire.com

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

Предыдущее
От: Neil Conway
Дата:
Сообщение: Re: using limit with delete
Следующее
От: Mike Rylander
Дата:
Сообщение: Re: COPY command use UTF-8 encoding and NOT UNICODE(16bits)... please confirm. Should postgresql add :set CLIENT_ENCODING to 'UTF-8'; to avoid confusion