Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我将时间存储为 VARCHAR(30),如下所示:
我知道这与最佳实践相去甚远.. 有什么方法可以将这样的字符串转换为 PostgreSQL 的时间?
简单的铸造可以做到这一点:
SELECT time::timestamptz FROM table;
证明:
SELECT '2016-08-12T15:15:01.100001Z'::timestamptz; timestamptz ------------------------------- 2016-08-12 15:15:01.100001+00
(1 行)