Re: Howto define a constraint in a existing column

Поиск
Список
Период
Сортировка
От Thomas Kellerer
Тема Re: Howto define a constraint in a existing column
Дата
Msg-id h5m540$oul$1@ger.gmane.org
обсуждение исходный текст
Ответ на Howto define a constraint in a existing column  (Intengu Technologies <sindile.bidla@gmail.com>)
Ответы Re: Howto define a constraint in a existing column  (Intengu Technologies <sindile.bidla@gmail.com>)
Список pgsql-novice
Intengu Technologies wrote on 09.08.2009 11:23:
> I am tying to define a primary key constraint to an existing table,
> this is what I have tried so far
>
> ALTER TABLE mytable ALTER COLUMN field13 CONSTRAINT name PRIMARY KEY;
>
> I get the following error: ERROR: syntax error at or near "CONSTRAINT"
> SQL state: 42601
> Character: 61
>
That should be

ALTER TABLE mytable
    ADD PRIMARY KEY (field13);

Or if you want to give the constraint a name:

ALTER TABLE mytable
    ADD CONSTRAINT pk_mytable PRIMARY KEY (field13);

Thomas

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

Предыдущее
От: Intengu Technologies
Дата:
Сообщение: Howto define a constraint in a existing column
Следующее
От: Intengu Technologies
Дата:
Сообщение: Re: Howto define a constraint in a existing column