Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add integer column with default of unix timestamp (epoch) in PostgreSQL?

This doesn't work:

create table event (
...
time int default date_part('epoch', timestamp 'now'),
...
);
like image 611
hegemon Avatar asked Nov 15 '25 01:11

hegemon


1 Answers

I'm no postgresql expert but shouldn't this one work

time int default date_part('epoch', now())
like image 81
jitter Avatar answered Nov 17 '25 20:11

jitter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!