ALTER TABLE

NOT NULL制約をつける

 ALTER TABLE users ALTER tel SET not null;

ユニーク制約をつける

 ALTER TABLE member ADD CONSTRAINT login_id_passwd_key UNIQUE (login_id, passwd)

主キーの削除

 ALTER TABLE users DROP CONSTRAINT users_pkey;

主キーの追加

 ALTER TABLE users ADD primary key ( user_id );

型変更

 ALTER TABLE users ALTER birth_day TYPE timestamp

birth_dayを(date型などから)timestamp型に変える。

テーブル名変更

 ALTER TABLE users RENAME TO users2;

所有者変更

 ALTER TABLE users OWNER to new_owner;

参考

http://stackoverflow.com/questions/1348126/modify-owner-on-all-tables-simultaneously-in-postgresql

参考

http://www.postgresql.jp/document/current/html/sql-altertable.html


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS

Last-modified: 2013-12-17 (火) 03:03:35