我设置了许多模式:
方案:
hg=# \dn
_timescaledb_cache | postgres
_timescaledb_catalog | postgres
_timescaledb_internal | postgres
hg_quotes_raw | zoolander
hg_trade_volume_1m | zoolander
hg_trade_volume_day | zoolander
hg_trades_raw | zoolander
public | postgres
在每个hg_xxx
模式中,我都有许多表(大多数具有公用表名):
hg_quotes_raw:
hg=# \dt hg_quotes_raw.*
hg_quotes_raw | hgf7 | table | zoolander
hg_quotes_raw | hgf8 | table | zoolander
...
hg_quotes_raw | hgz6 | table | zoolander
hg_quotes_raw | hgz7 | table | zoolander
hg_trade_volume_1m:
hg=# \dt hg_trade_volume_1m.*
hg_trade_volume_1m | hgf7 | table | zoolander
hg_trade_volume_1m | hgf8 | table | zoolander
...
hg_trade_volume_1m | hgz6 | table | zoolander
hg_trade_volume_1m | hgz7 | table | zoolander
我有一个这样的表hg_trade_volume_1m.hgq8
,如下所示:
hg=# \d hg_trade_volume_1m.hgq8
time | timestamp with time zone | | not null |
volume | integer | | |
hg=# select * from hg_trade_volume_1m.hgq8 limit 5;
2016-12-16 09:32:00-05 | 88
2016-12-16 13:45:00-05 | 88
2016-12-22 13:42:00-05 | 86
2017-01-04 11:43:00-05 | 43
2017-01-04 13:38:00-05 | 22
当我尝试删除该表时,收到一条错误消息,提示不存在不同的模式:
hg=# drop table if exists hg_trade_volume_1m.hgq8;
ERROR: schema "hg_raw_quotes" does not exist
我的表在以下drop语句之后仍然存在:
hg=# \d hg_trade_volume_1m.hgq8
time | timestamp with time zone | | not null |
volume | integer | | |
hg=# select * from hg_trade_volume_1m.hgq8 limit 5;
2016-12-16 09:32:00-05 | 88
2016-12-16 13:45:00-05 | 88
2016-12-22 13:42:00-05 | 86
2017-01-04 11:43:00-05 | 43
2017-01-04 13:38:00-05 | 22
该错误消息中提到的模式曾经存在,但此后已从数据库中删除。
hg=# \dn hg_raw_quotes
还请注意,该表(及相关的timescaledb超表)并非最初在架构中创建的,而是在创建后迁移到架构的。不知道这可能是根本原因吗?