Questions tagged «postgresql-9.1»

针对9.1版的PostgreSQL问题。

4
在PostgreSQL中生成两个日期之间的时间序列
我有这样的查询,它很好地生成了两个给定日期之间的一系列日期: select date '2004-03-07' + j - i as AllDate from generate_series(0, extract(doy from date '2004-03-07')::int - 1) as i, generate_series(0, extract(doy from date '2004-08-16')::int - 1) as j 它在2004-03-07和之间生成162个日期2004-08-16,这正是我想要的。该代码的问题在于,当两个日期来自不同年份时(例如,当我尝试使用2007-02-01和时),它将无法给出正确的答案2008-04-01。 有更好的解决方案吗?


2
如何断开数据库连接并返回到PostgreSQL中的默认数据库?
我正在使用PostgreSql版本: postgres=# select version(); version ------------------------------------------------------------- PostgreSQL 9.2.4, compiled by Visual C++ build 1600, 64-bit (1 row) 我从连接到数据库postgres=#来newdb=#....现在我在newdb=#数据库中,我想拔掉,然后返回到postgres=#数据库.... 这该怎么做 ? 我尝试过 disconnect newdb; 但它给人的错误是: postgres=# create database newdb; CREATE DATABASE postgres=# \c newdb; WARNING: Console code page (437) differs from Windows code page (1252) 8-bit characters might not work correctly. …

1
找不到从未知到文本的转换功能
在我的选择语句之一中,出现以下错误: ERROR: failed to find conversion function from unknown to text ********** Error ********** ERROR: failed to find conversion function from unknown to text SQL state: XX000 使用可以轻松修复此问题cast,但我不完全了解为什么会发生。我将用两个简单的陈述来说明我的困惑。 这是可以的: select 'text' union all select 'text'; 这将返回错误: with t as (select 'text') select * from t union all select 'text' 我知道我可以轻松解决它: …

4
postgres,ubuntu如何在启动时重启服务?实例重新启动后陷入群集
我Postgres db 9.1正在跑步AWS EC2,与ubuntu 12.04。 我对该实例弄得一团糟(即在我决定使用9.1之前安装了各种postgres XX)。 现在,在该数据库上工作了一个月后,我发现如果重新启动实例postgres无法正确加载,其状态将显示为“正在运行群集”。这将一直持续到我 sudo service postgresql restart 从终端,然后再次工作。 如何将此行添加到ubuntu启动中,以便每次加载时都将重新启动该服务,并有望解决我的问题? 还有可能解决此问题的任何其他解决方案。
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.