Re: Trigger/Function Problem

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Re: Trigger/Function Problem
Дата
Msg-id Pine.LNX.4.30.0102122205320.1100-100000@peter.localdomain
обсуждение исходный текст
Ответ на Trigger/Function Problem  (kowal@nawigator.pl)
Список pgsql-general
kowal@nawigator.pl writes:

>                                 Table "mp3user"
>      Attribute   |    Type     |                     Modifier
> --------------+-------------+--------------------------------------------------
>
>        id           | integer     | not null default
> nextval('mp3user_id_seq'::text)
>       nick         | varchar(20) |
>
>                  Table "mp3user_data"
>  Attribute    |    Type        |       Modifier
> ------------+-------------+----------------------
> id               | integer        | not null
> imie            | varchar(30)  | not null
> nazwisko     | varchar(30)  | not null
>
> I have to table looking like the above (only bigger).
>
> What I want to do I to set a trigger which ON DELETE from "mp3user"
> table
> will automatically DELETE a row from "mp3user_data" table.

Looks like you want to use a foreign key.  Declare your mp3user_data table
something like this:

CREATE TABLE mp3user_data (
  id integer references mp3user on delete cascade,
  ...
);

See http://www.postgresql.org/users-lounge/docs/7.0/user/sql-createtable.htm
for details.

--
Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/


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

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: ALTER DROP COLUMN
Следующее
От: jdassen@cistron.nl (J.H.M. Dassen (Ray))
Дата:
Сообщение: Re: PostgreSQL vs Oracle vs DB2 vs MySQL - Which should I use?