问题标签 [postgresql-9.3]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
postgresql - 运算符不存在:整数[] @@整数[]
我已将一个 intarray 列添加到我的表中,并成功地将数据添加到该列中。
当我尝试这样的查询时:
我收到此错误:
我通过 Homebrew for OS X 安装了 9.3,我相信它包含该intarray
模块,就像我说的那样,我添加了数组列和数据没问题。还有这个:
更新:
我想知道在操作员工作之前是否需要一个特定的索引。在文档的示例中,他们添加了如下索引:
但是当我运行时,我得到:
我是否缺少扩展名或查询有问题或什么?
sql - Avoid duplicate values in a column
My Table table1
looks like this:
I want to retrieve the value without duplicate no
and split the name
using "," so I tried like this:
But it return no duplicate. I want to get the value
- No duplicate in
no
column - Name have same
no
. It merage using ',' like this (no 1 name with split(',') C_GT_2013-2014,C_GT_2014-2015
)
I am using Postgresql 9.3.
My result would be:
I want to split Name into three columns which word have master its comes to Master column, Which word have its Comes to AcMaster, Others Comes to Trans With out No duplicate
sql - Postgresql JSON 有密钥
我试图了解Postgresql
处理的方式JSON
。我已经声明了一个包含两列的表,我想创建一个新视图来获取一些布尔值。
到目前为止,我已经能够将值作为文本获取,但我想得到的是该字段是否已定义。例如,如果JSON
有 key frameMenuData.frameElement
,它应该打印has_frame
为 true。
上面的代码给了我该行的内容。我需要知道是否customer_data->>'frameMenuData'->>'frameElement'
已定义。
我怎么能做到这一点?
谢谢你的帮助。
json - 如何在 PostgreSQL 9.3 中索引 JSON 数据,当它的 key 未知时?
有谁知道如何在 PostgreSQL 9.3 中为以下 JSON 数据创建索引?
示例数据:
说如果我想索引所有键怎么做?
谢谢。
ruby-on-rails - 生产服务器上的 Rgeo geom nil
我有一个非常奇怪的错误,希望这里有人能提供帮助。我已经将一个形状文件导入到我的 rails postgis 数据库中。它包含以下列:
- 搜索
- 资源
- 搜索2
- 重复
- 几何
geom 列包含一个 RGeo MultiPolygon 坐标。
奇怪的是我的本地 Rails 应用程序在读取所有记录 geom 字段时没有问题,但是我的生产服务器有一些记录在 geom 字段中为零。
这两个应用程序在 git 中具有完全相同的代码,并且正在查看完全相同的数据库。
这两个应用程序之间的唯一区别是我的本地应用程序在 OSX 上运行,而生产在 Ubuntu 12.04 上运行。
以下是一些有助于诊断问题的代码片段:
配置/数据库.yml
应用程序/模型/地名词典.rb
宝石文件
如果您能想到任何其他有用的东西,请告诉我,我会尽快提供。
更新 1
因此,我在两个系统上安装 postgresql 和 postgis 的方式存在差异。在 OSX(本地)上,我安装了 opengeo 软件套件,其中包含我需要的所有组件。在 Ubuntu(生产)上,我使用 apt-get 安装了 postgresql-9.3。
感谢这里的评论,我注意到我没有在生产服务器上安装一些东西,比如 geos 和 gdal。我都安装了,不幸的是仍然有同样的错误。
更新 2
所以我决定尝试让生产服务器与我的本地机器接近相同的环境,看看这是否能解决我的问题。我删除了 postgres/postgis/geos 的 apt 安装并安装了 Ubuntu opengeo 软件套件。这是我在本地机器上使用的。
不幸的是,这并没有解决问题。
然后我注意到我使用的是不同版本的 ruby。所以我更新了我的生产服务器以使用相同的版本(ruby 2.0.0p247)。
仍然没有解决错误。
我仍然对这个错误感到困惑。看来这一定与 rails、rgeo 或 activerecord-postgis-adapter gem 有关。
更新 3
因此,我注意到两个系统上的几何记录之间存在差异。我查看了数据库中的第一条记录,在 geom 字段中都有几何,但是平台之间的 Rgeo 类型不同。
本地服务器 (OSX)
RGeo::Geos::CAPIMultiPolygonImpl:0x3fc7af864fdc "MULTIPOLYGON ..."
生产服务器(Ubuntu 12.04)
RGeo::Geographic::SphericalMultiPolygonImpl:0x1b07a4c "MULTIPOLYGON ..."
似乎无法将 RGeo::Geographic 对象转换为 RGeo::Geos 坐标。
sql - 如何使用任意键的postgresql JSON?
我在表格 t1 中有一个 JSON 字段 c1,其格式为
我想找到任何键状态为 1 的 t1 行,我尝试过以下命令
但它没有给我任何行吗?
sql - postgresql 按大小列出和排序表
如何列出PostgreSQL 数据库的所有表并按大小排序?
sql - PostgreSQL: Counting Data is very slow while using JSON
I was playing around with PostgreSQL9.3 and decided to try out the JSON type. So I wrote a Query which counts certain JSON Data and groups them by a user_id, but the process took very long to finish. Could somebody give me a hint to improve the performance?
But let me show you the test data and the relations first:
I downloaded some test data which contained one JSON Document per line. The JSON Document was composed out of one array named "hashtags", one array named "urls" and one field with a field named "user_id" (non-unique).
Test data:
Then I created a simple relation with an auto-incrementing primary key and a column which contains an JSON type like this:
I loaded the data into postgresql where one JSON Document now equals one row:
Now I wanted to know how often a hastag was used by a certain user_id. To do that I had to use a sub-query which used the json_array_elements() function. The function takes a specified JSON array and turns it into a column.
The Query looks like this:
I got the result I wanted, but the query took very long to finish. For example I loaded 200.000 JSON Documents into postgresql, which is slightly less than 25MB, and it took around 10mins until I got a result. I also tried various indexes, but the performance only improved by half a minute at best.
Now being a postgresql beginner I ask myself, if it is really that slow or did I do something wrong? if it is the latter, what can I do against it?
Your help will be much appreciated.
postgresql - 如果 Postgresql 中不存在则添加列
postgresql ( 9.3.2 ) 可以在添加新列之前检查列的存在吗?我不想仅仅为了检查存在而创建一个函数。
就像这样:
java - Postgres jdbc 驱动程序的编码问题
我使用 9.3-1100-jdbc4 驱动程序,并在 Eclipse 中将 UTF-8 作为默认编码。当我运行我的应用程序时,我得到堆栈跟踪,但我无法读取它
打开会话时出错。原因:org.postgresql.util.PSQLException: �����: ������������ "root" �� ������ �������� ��� �������� (�� ������)
我是这样看的。有可能解决这个问题吗?