我已经使用MySQL多年了,现在我需要使用Postgresql。
我遇到了很多问题,使得微不足道的SQL工作,我不知道为什么它不起作用。
首先是我的数据:
Momentive-> \d+ "OHLCData";
Did not find any relation named ""OHLCData"".
Momentive-> \d+ "MomentiveData"."OHLCData";
Table "MomentiveDat
a.OHLCData"
Column | Type | Modifiers
| Storage | Stats target | Description
---------------+------------------+---------------------------------------------
---------------------------------+----------+--------------+-------------
ohlc_id | integer | not null default nextval('"MomentiveData"."O
HLCData_ohlc_id_seq"'::regclass) | plain | |
OHLCDataSetID | integer | not null
| plain | |
Date | character(20) | not null
| extended | |
EpochTime | integer | not null
| plain | |
Open | double precision | not null
| plain | |
High | double precision | not null
| plain | |
Low | double precision | not null
| plain | |
Close | double precision | not null
| plain | |
Indexes:
"OHLCData_pkey" PRIMARY KEY, btree (ohlc_id)
"Date" btree ("Date")
"EpochTime" btree ("EpochTime")
Foreign-key constraints:
"OHLCData_OHLCDataSetID_fkey" FOREIGN KEY ("OHLCDataSetID") REFERENCES "Mome
ntiveData"."OHLCDataSets"("OHLCDataSetID")
Has OIDs: no
第一个问题,为什么我需要始终将模式名称放在它前面以对表做任何事情?有没有相当于"使用数据库"来自MySQL?
由于我的应用需求,我故意将日期信息存储为字符串。所以我想进入一个"琐事"选择如:
SELECT * FROM "MomentiveData"."OHLCData" AS t1 WHERE t1."Date" >= "2010-01-03 00:00:00" AND t1."Date" <= "2010-01-03 23:59:59";
我收到以下错误:
Error in query: ERROR: column "2010-01-03 00:00:00" does not exist
LINE 1: ...omentiveData"."OHLCData" AS t1 WHERE t1."Date" >= "2010-01-0...
WTF?如何将我的数据点与列名混淆? 该如何构建?
感谢名单
PS,我用adminer.php来创建表,我用psql作为例子。我实际上已经填充了表格。