简体   繁体   中英

How to automatically update the updated date column on updating row in RedShift?

I have a table in Redshift which has an UpdatedDate column of type timestamp. The column is defined as

UpdatedDate timestamp DEFAULT getdate()

So when ever a new record is inserted the date is stored correctly in this column. The issue is in the update case. In update this column is not updated. What I need is for UpdatedDate column to update automatically when the data in the row is changed.

I know we can specify the column in the update query, but I do not have control over the query and cannot add the column there.

I tried using Triggers but Redshift does not seem to support them. Thanks for your time. Let me know if any other information is needed.

Create Staging table for this purpose. Refer Upsert in Redshift: https://docs.aws.amazon.com/redshift/latest/dg/merge-specify-a-column-list.html

During update statement, set update_ts = sysdate.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM