我有以下employees
表定义
CREATE TABLE employees
(
id integer NOT NULL,
name text,
withouttz timestamp without time zone,
withtz timestamp with time zone,
CONSTRAINT primarykey_emp PRIMARY KEY (id)
)
WITH (
OIDS=FALSE
);
ALTER TABLE employees
OWNER TO chris;
我通过以下方式插入了两条记录:
INSERT INTO employees(
id, name, withouttz, withtz)
VALUES (1, 'test', '2011-01-01 00:00:00', '2011-01-01 12:00:00+03');
INSERT INTO employees(
id, name, withouttz, withtz)
VALUES (2, 'test', '2011-01-01 00:00:00', '2011-01-01 12:00:00');
我编写了简单的 java 类,select * from employees
它输出以下内容:
col1: 1
col2: test
col3: 2011-01-01 00:00:00
col4: 2011-01-01 07:00:00-8:00
col1: 2
col2: test
col3: 2011-01-01 00:00:00
col4: 2011-01-01 12:00:00-8:00
问题:有没有办法创建一个 postgres 表timestamp with time zone
,以便它认为时区是 UTC 而不是服务器的本地时区?
注意:set timezone TO 'GMT';
对我来说不是解决方案,因为它仅在特定会话中有效。此外,如果解决方案完全不依赖于服务器的本地时区,那就太好了
提前致谢