[pgsql-jp: 36054] Re: WITHOUT OIDSへの変更

Kiyoshi Mizuno kiyoshi_mizuno @ mail.toyota.co.jp
2005年 9月 29日 (木) 10:40:00 JST


水野です。


> -----Original Message-----
> 7.2.8で「WITH OIDS」オプションで作成した表を
> 「WITHOUT OIDS」に変更したいです。

マニュアル(第 5章データ定義 5.2システム列)を読んだら
OIDはシステム列という暗黙のカラムだと書いてあったので、
それではと試してみました。

template1=# create table test ( product_no integer,name text,price numeric);
CREATE TABLE
template1=# select oid from test;
 oid
-----
(0 行)

template1=# alter table test drop oid;
ALTER TABLE
template1=# select oid from test;
ERROR:  column "oid" does not exist

という感じでレコードのOID列は削除できちゃいました。
なおtableoid列については

template1=# create table test2 ( test numeric) without OIDS;
CREATE TABLE
template1=# select oid from test2;
ERROR:  column "oid" does not exist
template1=# select tableoid from test2;
 tableoid
----------
(0 行)

という事で残すのが正しいようです。
ただしこのような方法によって変な副作用が出ない保証はありませんから、
正論は「表を再作成しましょ」という事で。





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