Postgresql日付と時間タイプ
1937 ワード
timestamp with[out] time zone ( )
time with[out] time zone ( )
。MySQL 。
, with time zone。
highgo=# select time '120900';
time
----------
12:09:00
(1 row)
highgo=# select time '120900 PST';
time
----------
12:09:00
(1 row)
highgo=# select time WITH time zone '120900 PST';
timetz
-------------
12:09:00-08
(1 row)
, 。 datestyle。
highgo=# create table t(date date);
CREATE TABLE
highgo=# insert into t values (date '12-18-2010');
INSERT 0 1
highgo=# select * from t;
date
------------
2010-12-18
(1 row)
highgo=# show datestyle;
DateStyle
-----------
ISO, MDY
(1 row)
highgo=# set datestyle = 'YMD';
SET
highgo=# insert into t values (date '2010-12-19');
INSERT 0 1
highgo=# select * from t;
date
------------
2010-12-18
2010-12-19
(2 rows)
: 2017-12-18 。 2017 12 18 。
PostgreSQL 。
:
CURRENT_DATE
CURRENT_TIME
CURRENT_TIMESTAMP
CURRENT_TIME(precision)
LOCALTIME
LOCALTIMESTAMP
now()
transaction_timestamp()
, 。
statement_timestamp()
clock_timestamp()
timeofday() text
, now() , statement_timestamp() 。
highgo=# begin;
BEGIN
highgo=# select now();
now
-------------------------------
2017-12-18 12:18:32.263891+08
(1 row)
highgo=# select now();
now
-------------------------------
2017-12-18 12:18:32.263891+08
(1 row)
highgo=# select statement_timestamp();
statement_timestamp
-------------------------------
2017-12-18 12:19:15.463267+08
(1 row)
highgo=# select statement_timestamp();
statement_timestamp
-------------------------------
2017-12-18 12:19:18.975693+08
(1 row)
highgo=# commit;
COMMIT
By