Re: adding on delete cascade constraint?

Поиск
Список
Период
Сортировка
От Oliver Elphick
Тема Re: adding on delete cascade constraint?
Дата
Msg-id 1063978867.18550.1382.camel@linda.lfix.co.uk
обсуждение исходный текст
Ответ на Re: adding on delete cascade constraint?  (Jean-Christian Imbeault <jc@mega-bucks.co.jp>)
Список pgsql-general
On Fri, 2003-09-19 at 14:02, Jean-Christian Imbeault wrote:
> Oliver Elphick wrote:
>
> >>Foreign Key constraints: $1 FOREIGN KEY (pid) REFERENCES products(id) ON
> >>UPDATE NO ACTION ON DELETE NO ACTION
> >
> > Drop the constraint; then add an amended one.
>
> Ok, how do I drop the constraint, it has no name.

From what you quoted above, its name is $1

ALTER TABLE xxx DROP CONSTRAINT "$1"; -- double quotes required since
                                      -- $1 is an identifier

> Secondly what is the correct syntax for adding a new constraint with ON
> DELETE CASCADE?

ALTER TABLE xxx ADD CONSTRAINT "$1" FOREIGN KEY (pid) REFERENCES
products(id) ON UPDATE NO ACTION ON DELETE CASCADE;

--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight, UK                             http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "Bring ye all the tithes into the storehouse, that
      there may be meat in mine house, and prove me now
      herewith, saith the LORD of hosts, if I will not open
      you the windows of heaven, and pour you out a
      blessing, that there shall not be room enough to
      receive it."           Malachi 3:10


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

Предыдущее
От: Xavier Ambrosioni
Дата:
Сообщение: Access Ingres database
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: adding on delete cascade constraint?