2017-08-06 13 views
0

既存のテーブルにデフォルトのタイムスタンプカラムを作成したいと思います。PostgreSQLでのデフォルトのタイムスタンプの作成

私の最初のクエリでは、これが動作し、成功した列を追加し

"ALTER TABLE {table_name} ADD COLUMN modifiedDate timestamp without time zone"

です。

は、しかし、2番目のクエリ

ALTER TABLE {table_name} ALTER modifiedDate SET DEFAULT '2001-01-01 00:00:00'::timestamp without time zone;

は、そのタイムスタンプを含むように列にすべての行を更新するために失敗しました。

私はthis SO postに従っていました。

また、私は1つのクエリ

"ALTER TABLE {table_name} ADD COLUMN modifiedDate timestamp without time zone" SET DEFAULT '2001-01-01 00:00:00'::timestamp without time zone;

にしようとしたが、それはエラーにsyntax error at or near "00"

答えて

0

愚かな間違いを与えました。

ALTER TABLE {table_name} ADD COLUMN modifiedDate timestamp without time zone NOT NULL DEFAULT '2001-01-01 00:00:00'::timestamp without time zone;

SETは1つのライナーであってはなりません。

関連する問題