我正在尝试第一次设置Postgres,我需要创建一个具有读取和创建数据库权限的用户.但是,当我在终端中使用"createuser username"时,我收到以下消息:
createuser:无法连接到数据库postgres:致命:角色"tom"不存在
Tom是我现在登录的Ubuntu用户帐户.我正在尝试创建"postgres"的用户名,然后执行"psql -U psql template1",这样我就可以创建一个数据库并为我的Rails应用程序分配一个所有者.
有帮助吗?
我正在尝试使用 pgAdmin 加载 tar 文件,但它失败了,我得到的只是退出代码 3221225781。此代码似乎表明缺少 dll Windows 上的退出代码 3221225781 是什么?但我不确定为什么会这样或者要寻找什么 dll。
我在Rails 2.3.8上使用PostgreSQL数据库,我需要在我的表上重启自动增量ID.我怎样才能做到这一点?
我有这个查询
select * from sales
shop | date | hour | row_no | amount
-----------+------------+-----------+--------+-----------
shop_1 | 2012-08-14 | 00:08:00 | P01 | 10
shop_2 | 2012-08-12 | 00:12:00 | O05 | 40
shop_2 | 2012-08-12 | 00:12:00 | A01 | 20
Run Code Online (Sandbox Code Playgroud)
我有 100 万行,我可以做这个查询
select shop, SUM(amount)
from sales
group by shop
shop | amount |
-----------+------------+
shop_1 | 5666 |
shop_2 | 4044 |
shop_3 4044 |
Run Code Online (Sandbox Code Playgroud)
但是我需要在专栏上度过几天,我不知道他们是否可以帮助我做到这一点
shop | 2012-08-1 | 2012-08-2 | 2012-08-3 |
-----------+------------+-----------+--------+-----------
shop_1 …
Run Code Online (Sandbox Code Playgroud) 我无法date
在PostgreSQL 9.6表中插入.
这是INSERT查询:
INSERT INTO rates (idproperty, from, to, price)
VALUES (1, '2017-03-14', '2017-04-30', 130);
Run Code Online (Sandbox Code Playgroud)
这就是结果:
ERROR: syntax error at or near "from"
LINE 1: INSERT INTO rates (idproperty, from, to, price)
Run Code Online (Sandbox Code Playgroud)
列from
和to
使用数据类型定义date
.
谢谢