[pgsql-jp: 25878] Re: 主キー作成方法について

Satoshi Nagayasu snaga @ oak.forus.or.jp
2002年 5月 9日 (木) 16:37:26 JST


永安です。

"Tadashi Kanbayashi" wrote:
> 神林ともうします。
> 教えてください。
> 
> 主キー制約を、あとづけで作成したいと思っておりますが、
> ERROR:ALTER TABLE/ADD CONSTRAINT is not implemented for that constraint
> type.
> とエラーになります。

「not implemented」と出てますが。。。


> 具体的には、テーブルT_MIMINFのMIDを主キーにする場合、
> 以下のSQLを実行しています。
> 
> alter table T_MIMINF drop constraint PK_T_MIMINF; --主キ制約PK_T_MIMINFを
> 削除
> alter table T_MIMINF add constraint PK_T_MIMINF primary key(MID); --主キー
> 作成
> 
> 方法を教えてください。

バージョン7.2以降でないとできないと思います。

| In the current implementation, only FOREIGN KEY constraints can be
| added to a table. To create or remove a unique constraint, create a
| unique index (see CREATE INDEX). To add check constraints you need to
| recreate and reload the table, using other parameters to the CREATE
| TABLE command.

http://www.ca.postgresql.org/users-lounge/docs/7.1/postgres/sql-altertable.html


7.2のマニュアルには、この記述はありません。

http://www.ca.postgresql.org/users-lounge/docs/7.2/postgres/sql-altertable.html

-- 
NAGAYASU Satoshi <snaga @ oak.forus.or.jp>



pgsql-jp メーリングリストの案内