Re: From select to delete

Поиск
Список
Период
Сортировка
От David Johnston
Тема Re: From select to delete
Дата
Msg-id 00e701cc9593$26847d90$738d78b0$@yahoo.com
обсуждение исходный текст
Ответ на From select to delete  (Alexander Farber <alexander.farber@gmail.com>)
Ответы Re: From select to delete
Список pgsql-general
-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org] On Behalf Of Alexander Farber
Sent: Friday, October 28, 2011 12:34 PM
To: pgsql-general
Subject: [GENERAL] From select to delete

Hello,

Is there maybe an easy way to delete that player (and all his games and
partners) or do I have to work with temp tables?

---/Original Message------

The easiest way is to create FOREIGN KEY relationships between the various
tables and allow "ON DELETE CASCADE" to do the work.

Otherwise you need to DELETE with an appropriate WHERE clause (and
sub-selects) or you can use the "USING" clause with the DELETE to add
additional condition tables.

DELETE FROM t1
USING (t2 JOIN t3 ON (...)) t_linked
WHERE t1.something = t_linked.something;

See the SQL Command (DELETE) section of the documentation for more details
and examples of DELETE
See the SQL Command (CREATE TABLE ) section of the documentation for
information on how to setup FOREIGN KEYS

David J.




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

Предыдущее
От: Merlin Moncure
Дата:
Сообщение: Re: nextval skips values between consecutive calls
Следующее
От: Alexander Farber
Дата:
Сообщение: Re: From select to delete