Reputation: 1747
After research on here I wanted to use "timestamp with time zone" but cannot figure out the proper syntax based on the postgres docs.
ALTER TABLE microwaves ADD COLUMN scanned_in DATA_TYPE timestamp with time zone;
ALTER TABLE microwaves ADD COLUMN scanned_in TYPE timestamp with time zone;
Both throw errors.
Any help appreciated, thanks.
Upvotes: 13
Views: 27110
Reputation: 830
Follow the simple solution as below:
ALTER TABLE microwaves ADD COLUMN scanned_in timestamp with time zone;
For more details check PostgreSQL - ADD COLUMN
Upvotes: 2
Reputation: 44250
You just had the syntax wrong. You don't need the [DATA] TYPE
part here (that's only needed when you want to change the type) :
CREATE TABLE barf
( id serial PRIMARY KEY);
ALTER TABLE barf ADD COLUMN scanned_in timestamp with time zone;
BTW (just a hint): most of the ALTER
syntax just mimics the syntax for CREATE TABLE (...)
: the sub-syntax is mostly the same.
Upvotes: 22