Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
時間に関して列フィールドを更新するために、PostgreSQLである種の関数またはトリガーを作成することは可能ですか?
たとえば、今日はフィールドを 1 にして、10 時間後には 0 にします。
これは可能ですか?
値が時間のみの関数である場合は、クエリ時に計算できます。これは常に 0 または 1 になります。
select (extract(hour from current_time) >= 12)::int * 1; ?column? ---------- 0
またはビューに追加:
create view v as select *, (extract(hour from current_time) >= 12)::int * 1 from t;