LoginSignup
3
2

More than 3 years have passed since last update.

PostgreSQLでTIMESTAMPカラムにデフォルトでINSERT時刻を設定する場合

Posted at

(ちょっと詰まっていろいろ試したので、備忘録に・・・)

psql -V
psql (PostgreSQL) 10.10 (Ubuntu 10.10-0ubuntu0.18.04.1)

テーブル作成時・・・
CREATE TABLE time_table ( time_column timestamp default "timestamp"('now'::text) );

カラム変更時・・・
alter table time_table alter column time_column set default "timestamp"('now'::text);

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2