9

I want to create a timestamp column with a default value of epoch. How can I do it? This, and all the variations I've tried don't work:

...
last_viewed_at     TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT TIMESTAMP "epoch",
...
3
  • DEFAULT current_timestamp Commented Sep 28, 2015 at 20:24
  • Epoch means 1970-01-01 00:00:00 Commented Sep 28, 2015 at 20:25
  • then write that explicitely: timestamp '1970-01-01 00:00:00' Commented Sep 28, 2015 at 20:41

1 Answer 1

10

It's all about double quotes vs single quotes. Double quotes are for identifiers so you want:

...
last_viewed_at     TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT TIMESTAMP 'epoch',
...

fiddle

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.