Postgres Tips

From Wiki
Jump to: navigation, search

Select timestamps in Postgres:

SELECT extract(epoch FROM date) FROM table;

Insert a timestamp:

INSERT INTO comments (date) VALUES (1192565061::int4::abstime)

Select records older than 30 days:

SELECT * FROM table WHERE age(date) > interval '30 days';

Change database owner:

ALTER DATABASE name OWNER TO new_owner