postgresqlでカラムの型をtextからintegerに変える時
ALTER TABLE table_name ALTER COLUMN column_name type integer;
とやったところ
ERROR: column "column_name" cannot be cast to type "pg_catalog.int4"
と怒られた。
困ったぞと。
ぐぐったら、同じ現象の人にぶち当たり、こちらの方もぐぐって解決策を書いてくれてた。
ALTER TABLE table_name ALTER COLUMN column_name type integer using column_name ::integer;
とやればよいらしい。
確かにうまくいった。
参考URL
http://kapi.jp/kapi_blog/234
2009年05月20日
関連カテゴリ Postgres