timestamptz.out

来自「postgresql8.3.4源码,开源数据库」· OUT 代码 · 共 1,335 行 · 第 1/5 页

OUT
1,335
字号
---- TIMESTAMPTZ--CREATE TABLE TIMESTAMPTZ_TBL (d1 timestamp(2) with time zone);-- Test shorthand input values-- We can't just "select" the results since they aren't constants; test for-- equality instead.  We can do that by running the test inside a transaction-- block, within which the value of 'now' shouldn't change.  We also check-- that 'now' *does* change over a reasonable interval such as 100 msec.-- NOTE: it is possible for this part of the test to fail if the transaction-- block is entered exactly at local midnight; then 'now' and 'today' have-- the same values and the counts will come out different.INSERT INTO TIMESTAMPTZ_TBL VALUES ('now');SELECT pg_sleep(0.1); pg_sleep ---------- (1 row)BEGIN;INSERT INTO TIMESTAMPTZ_TBL VALUES ('now');INSERT INTO TIMESTAMPTZ_TBL VALUES ('today');INSERT INTO TIMESTAMPTZ_TBL VALUES ('yesterday');INSERT INTO TIMESTAMPTZ_TBL VALUES ('tomorrow');INSERT INTO TIMESTAMPTZ_TBL VALUES ('tomorrow EST');INSERT INTO TIMESTAMPTZ_TBL VALUES ('tomorrow zulu');SELECT count(*) AS One FROM TIMESTAMPTZ_TBL WHERE d1 = timestamp with time zone 'today'; one -----   1(1 row)SELECT count(*) AS One FROM TIMESTAMPTZ_TBL WHERE d1 = timestamp with time zone 'tomorrow'; one -----   1(1 row)SELECT count(*) AS One FROM TIMESTAMPTZ_TBL WHERE d1 = timestamp with time zone 'yesterday'; one -----   1(1 row)SELECT count(*) AS One FROM TIMESTAMPTZ_TBL WHERE d1 = timestamp(2) with time zone 'now'; one -----   1(1 row)COMMIT;DELETE FROM TIMESTAMPTZ_TBL;-- verify uniform transaction time within transaction blockBEGIN;INSERT INTO TIMESTAMPTZ_TBL VALUES ('now');SELECT pg_sleep(0.1); pg_sleep ---------- (1 row)INSERT INTO TIMESTAMPTZ_TBL VALUES ('now');SELECT pg_sleep(0.1); pg_sleep ---------- (1 row)SELECT count(*) AS two FROM TIMESTAMPTZ_TBL WHERE d1 = timestamp(2) with time zone 'now'; two -----   2(1 row)COMMIT;DELETE FROM TIMESTAMPTZ_TBL;-- Special valuesINSERT INTO TIMESTAMPTZ_TBL VALUES ('-infinity');INSERT INTO TIMESTAMPTZ_TBL VALUES ('infinity');INSERT INTO TIMESTAMPTZ_TBL VALUES ('epoch');-- Obsolete special valuesINSERT INTO TIMESTAMPTZ_TBL VALUES ('invalid');ERROR:  date/time value "invalid" is no longer supportedINSERT INTO TIMESTAMPTZ_TBL VALUES ('current');ERROR:  date/time value "current" is no longer supported-- Postgres v6.0 standard output formatINSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Invalid Abstime');ERROR:  date/time value "Invalid Abstime" is no longer supportedINSERT INTO TIMESTAMPTZ_TBL VALUES ('Undefined Abstime');ERROR:  date/time value "Undefined Abstime" is no longer supported-- Variations on Postgres v6.1 standard output formatINSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01.000001 1997 PST');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01.999999 1997 PST');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01.4 1997 PST');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01.5 1997 PST');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01.6 1997 PST');-- ISO 8601 formatINSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-01-02');INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-01-02 03:04:05');INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-02-10 17:32:01-08');INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-02-10 17:32:01-0800');INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-02-10 17:32:01 -08:00');INSERT INTO TIMESTAMPTZ_TBL VALUES ('19970210 173201 -0800');INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-06-10 17:32:01 -07:00');INSERT INTO TIMESTAMPTZ_TBL VALUES ('2001-09-22T18:19:20');-- POSIX format (note that the timezone abbrev is just decoration here)INSERT INTO TIMESTAMPTZ_TBL VALUES ('2000-03-15 08:14:01 GMT+8');INSERT INTO TIMESTAMPTZ_TBL VALUES ('2000-03-15 13:14:02 GMT-1');INSERT INTO TIMESTAMPTZ_TBL VALUES ('2000-03-15 12:14:03 GMT-2');INSERT INTO TIMESTAMPTZ_TBL VALUES ('2000-03-15 03:14:04 PST+8');INSERT INTO TIMESTAMPTZ_TBL VALUES ('2000-03-15 02:14:05 MST+7:00');-- Variations for acceptable input formatsINSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 10 17:32:01 1997 -0800');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 10 17:32:01 1997');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 10 5:32PM 1997');INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997/02/10 17:32:01-0800');INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-02-10 17:32:01 PST');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb-10-1997 17:32:01 PST');INSERT INTO TIMESTAMPTZ_TBL VALUES ('02-10-1997 17:32:01 PST');INSERT INTO TIMESTAMPTZ_TBL VALUES ('19970210 173201 PST');set datestyle to ymd;INSERT INTO TIMESTAMPTZ_TBL VALUES ('97FEB10 5:32:01PM UTC');INSERT INTO TIMESTAMPTZ_TBL VALUES ('97/02/10 17:32:01 UTC');reset datestyle;INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997.041 17:32:01 UTC');-- timestamps at different timezonesINSERT INTO TIMESTAMPTZ_TBL VALUES ('19970210 173201 America/New_York');SELECT '19970210 173201' AT TIME ZONE 'America/New_York';         timezone         -------------------------- Mon Feb 10 20:32:01 1997(1 row)INSERT INTO TIMESTAMPTZ_TBL VALUES ('19970710 173201 America/New_York');SELECT '19970710 173201' AT TIME ZONE 'America/New_York';         timezone         -------------------------- Thu Jul 10 20:32:01 1997(1 row)INSERT INTO TIMESTAMPTZ_TBL VALUES ('19970710 173201 America/Does_not_exist');ERROR:  time zone "america/does_not_exist" not recognizedSELECT '19970710 173201' AT TIME ZONE 'America/Does_not_exist';ERROR:  time zone "America/Does_not_exist" not recognized-- Check date conversion and date arithmeticINSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-06-10 18:32:01 PDT');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 10 17:32:01 1997');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 11 17:32:01 1997');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 12 17:32:01 1997');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 13 17:32:01 1997');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 14 17:32:01 1997');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 15 17:32:01 1997');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 1997');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 0097 BC');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 0097');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 0597');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 1097');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 1697');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 1797');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 1897');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 1997');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 2097');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 28 17:32:01 1996');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 29 17:32:01 1996');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mar 01 17:32:01 1996');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 30 17:32:01 1996');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 31 17:32:01 1996');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Jan 01 17:32:01 1997');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 28 17:32:01 1997');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 29 17:32:01 1997');ERROR:  date/time field value out of range: "Feb 29 17:32:01 1997"INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mar 01 17:32:01 1997');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 30 17:32:01 1997');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 31 17:32:01 1997');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 31 17:32:01 1999');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Jan 01 17:32:01 2000');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 31 17:32:01 2000');INSERT INTO TIMESTAMPTZ_TBL VALUES ('Jan 01 17:32:01 2001');-- Currently unsupported syntax and rangesINSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 -0097');ERROR:  time zone displacement out of range: "Feb 16 17:32:01 -0097"INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 5097 BC');ERROR:  timestamp out of range: "Feb 16 17:32:01 5097 BC"-- Alternative field order that we've historically supported (sort of)-- with regular and POSIXy timezone specsSELECT 'Wed Jul 11 10:51:14 America/New_York 2001'::timestamptz;         timestamptz          ------------------------------ Wed Jul 11 07:51:14 2001 PDT(1 row)SELECT 'Wed Jul 11 10:51:14 GMT-4 2001'::timestamptz;         timestamptz          ------------------------------ Tue Jul 10 23:51:14 2001 PDT(1 row)SELECT 'Wed Jul 11 10:51:14 GMT+4 2001'::timestamptz;         timestamptz          ------------------------------ Wed Jul 11 07:51:14 2001 PDT(1 row)SELECT 'Wed Jul 11 10:51:14 PST-03:00 2001'::timestamptz;         timestamptz          ------------------------------ Wed Jul 11 00:51:14 2001 PDT(1 row)SELECT 'Wed Jul 11 10:51:14 PST+03:00 2001'::timestamptz;         timestamptz          ------------------------------ Wed Jul 11 06:51:14 2001 PDT(1 row)SELECT '' AS "64", d1 FROM TIMESTAMPTZ_TBL;  64 |               d1                ----+---------------------------------    | -infinity    | infinity    | Wed Dec 31 16:00:00 1969 PST    | Mon Feb 10 17:32:01 1997 PST    | Mon Feb 10 17:32:01 1997 PST    | Mon Feb 10 17:32:02 1997 PST    | Mon Feb 10 17:32:01.40 1997 PST    | Mon Feb 10 17:32:01.50 1997 PST    | Mon Feb 10 17:32:01.60 1997 PST    | Thu Jan 02 00:00:00 1997 PST    | Thu Jan 02 03:04:05 1997 PST    | Mon Feb 10 17:32:01 1997 PST    | Mon Feb 10 17:32:01 1997 PST    | Mon Feb 10 17:32:01 1997 PST    | Mon Feb 10 17:32:01 1997 PST    | Tue Jun 10 17:32:01 1997 PDT    | Sat Sep 22 18:19:20 2001 PDT    | Wed Mar 15 08:14:01 2000 PST    | Wed Mar 15 04:14:02 2000 PST    | Wed Mar 15 02:14:03 2000 PST    | Wed Mar 15 03:14:04 2000 PST    | Wed Mar 15 01:14:05 2000 PST    | Mon Feb 10 17:32:01 1997 PST    | Mon Feb 10 17:32:01 1997 PST    | Mon Feb 10 17:32:00 1997 PST    | Mon Feb 10 17:32:01 1997 PST    | Mon Feb 10 17:32:01 1997 PST    | Mon Feb 10 17:32:01 1997 PST    | Mon Feb 10 17:32:01 1997 PST    | Mon Feb 10 17:32:01 1997 PST    | Mon Feb 10 09:32:01 1997 PST    | Mon Feb 10 09:32:01 1997 PST    | Mon Feb 10 09:32:01 1997 PST    | Mon Feb 10 14:32:01 1997 PST    | Thu Jul 10 14:32:01 1997 PDT    | Tue Jun 10 18:32:01 1997 PDT    | Mon Feb 10 17:32:01 1997 PST    | Tue Feb 11 17:32:01 1997 PST    | Wed Feb 12 17:32:01 1997 PST    | Thu Feb 13 17:32:01 1997 PST    | Fri Feb 14 17:32:01 1997 PST    | Sat Feb 15 17:32:01 1997 PST    | Sun Feb 16 17:32:01 1997 PST    | Tue Feb 16 17:32:01 0097 PST BC    | Sat Feb 16 17:32:01 0097 PST    | Thu Feb 16 17:32:01 0597 PST    | Tue Feb 16 17:32:01 1097 PST    | Sat Feb 16 17:32:01 1697 PST

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?