所以我遇到了以下令我惊讶的行为。我首先认为DateTime可能是 postgres 数据类型,但 BidOpen 呢?然后是错误消息中列名的情况很有趣。我几乎觉得这与不区分大小写的未引用名称有关。为什么我需要用引号将列名括起来才能使查询起作用?
mydatabase=# select max("DateTime") from fx.candle;
max
---------------------
2019-04-26 20:59:00
(1 row)
mydatabase=# select max(DateTime) from fx.candle;
ERROR: column "datetime" does not exist
LINE 1: select max(DateTime) from fx.candle;
^
HINT: Perhaps you meant to reference the column "candle.DateTime".
mydatabase=# select max(BidOpen) from fx.candle;
ERROR: column "bidopen" does not exist
LINE 1: select max(BidOpen) from fx.candle;
^
HINT: Perhaps you meant to reference the column "candle.BidOpen".
mydatabase=# select max("BidOpen") from fx.candle;
max
---------
125.816
(1 row)
架构如下所示:
mydatabase=# \d fx.candle;
Table "fx.candle"
Column | Type | Modifiers
-----------+-----------------------------+-----------------------------------------------------------------
id | integer | not null default nextval('fx.candle_id_seq'::regclass)
DateTime | timestamp without time zone |
BidOpen | double precision | not null
BidHigh | double precision | not null
BidLow | double precision | not null
BidClose | double precision | not null
AskOpen | double precision | not null
AskHigh | double precision | not null
AskLow | double precision | not null
AskClose | double precision | not null
symbol_id | integer |
Indexes:
"candle_pkey" PRIMARY KEY, btree (id)
Foreign-key constraints:
"candle_symbol_id_fkey" FOREIGN KEY (symbol_id) REFERENCES fx.symbol(id)