Tag: postgresql

hibernate不能得到下一个序列值

我有gwt应用程序连接到后端postgres数据库,和一个Java类'判断'映射数据库中的表'判断',当我试图执行到数据库的判断,它抛出了以下错误: Caused by: org.hibernate.exception.SQLGrammarException: could not get next sequence value … Caused by: org.postgresql.util.PSQLException: ERROR: relation "hibernate_sequence" does not exist 我的审判class看起来像这样 @Entity @Table(name = "JUDGEMENTS") public class Judgement implements Serializable, Cloneable { private static final long serialVersionUID = -7049957706738879274L; @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "JUD_ID") private Long _judId; … 我的表格判断是: Column | Type | […]

fe_sendauth:没有提供密码

database.yml的: # SQLite version 3.x # gem install sqlite3 # # Ensure the SQLite 3 gem is defined in your Gemfile # gem 'sqlite3' development: adapter: postgresql encoding: utf8 database: sampleapp_dev #can be anything unique #host: localhost #username: 7stud #password: #adapter: sqlite3 #database: db/development.sqlite3 pool: 5 timeout: 5000 # Warning: The database defined as "test" […]

计算PostgreSQL中的累计和

我想查找字段的累积或运行量,并将其从登台插入到表中。 我的分期结构是这样的: ea_month id amount ea_year circle_id April 92570 1000 2014 1 April 92571 3000 2014 2 April 92572 2000 2014 3 March 92573 3000 2014 1 March 92574 2500 2014 2 March 92575 3750 2014 3 February 92576 2000 2014 1 February 92577 2500 2014 2 February 92578 1450 2014 3 我希望我的目标表看起来像这样: ea_month id […]

Postgres的:如何将JSONstring转换为文本?

Json值可能由一个sting值组成。 例如 postgres=# SELECT to_json('Some "text"'::TEXT); to_json —————– "Some \"text\"" 我怎样才能提取该string作为postgres文本值? ::TEXT不起作用。 它返回引用的JSON,而不是原始string: postgres=# SELECT to_json('Some "text"'::TEXT)::TEXT; to_json —————– "Some \"text\"" 谢谢。 PS我是美国PostgreSQL 9.3

Postgres将列整数更改为布尔值

我有一个字段是INTEGER不为NULL默认0,我需要改变为布尔。 这是我正在使用的: ALTER TABLE mytabe ALTER mycolumn TYPE bool USING CASE WHEN 0 THEN FALSE ELSE TRUE END; 但是我得到: ERROR: argument of CASE/WHEN must be type boolean, not type integer ********** Error ********** ERROR: argument of CASE/WHEN must be type boolean, not type integer SQL state: 42804 任何想法? 谢谢。

注释postgres / postgresql / psql中的字符/字符?

postgres中的评论字符是什么? SELECT * FROM my_table # pound sign produces a syntax error 谢谢cababunga,下面看来工作: SELECT * FROM my_table — this is my comment 但是这不起作用: \dt jvcurve_thin.jvcurve_results — my comment #2 \ dt:额外的参数“ – ”被忽略

PostgreSQL从3个表中join数据

我是PostgreSQL的新手,试图写一个查询。 我很确定对于一个知道自己在做什么的人来说很容易 – 我只是不知道! 🙂 基本上我有三张桌子。 首先,我存储有关患者的详细信息。 第二,我存储了每个图片的参考。 在第三,我存储链接到图像的文件path。 我没有devise数据库,所以我不知道为什么图像文件表是分开的,但它是。 我希望能够做的是从第一个表中select数据,从第二个和第三个表join数据,所以我最终在结果中的名称和文件path。 所以基本的结构是: Table 1: person_id | name Table 2: person_id | image_id Table 3: image_id | `path filename` 我想要做的是在一个查询中,抓住人的“名字”和图像“path文件名”。 我很满意与我需要的连接的“模板”样式的答案。 我不需要它写在实际的代码。 (即我想你可以只写我一个答案说:“SELECT table1.name,table3.pathfilename FROM JOIN … etc …”)。 谢谢!! 约翰

PostgreSQL用户列表

我想获取psql中某个数据库的用户列表,例如“template0”。 谁是用户? 或者对于“template1”数据库: – 那里的用户是谁? 已经尝试: \du+ — no database is Listed not Users Select * from "pg_users"; — no database is listed

如何自定义官方PostgreSQL Docker镜像的configuration文件?

我正在使用正式的Postgres Docker镜像尝试自定义其configuration。 为此,我使用命令sed来更改max_connections ,例如: sed -i -e"s/^max_connections = 100.*$/max_connections = 1000/" /var/lib/postgresql/data/postgresql.conf 我尝试了两种方法来应用此configuration。 首先是将命令添加到脚本中,并将其复制到init文件夹“/docker-entrypoint-initdb.d”中。 第二种方法是通过使用“RUN”命令直接在Dockerfile中运行它们(这种方法在configuration文件“/ etc / postgres / …”的非官方Postgresql映像中工作正常)。 在这两种情况下,更改失败,因为configuration文件丢失(我认为它还没有创build)。 我应该如何改变configuration? 编辑1: 以下是用于创build映像的Dockerfile: # Database (http://www.cs3c.ma/) FROM postgres:9.4 MAINTAINER Sabbane <contact@cs3c.ma> ENV TERM=xterm RUN apt-get update RUN apt-get install -y nano ADD scripts /scripts # ADD scripts/setup-my-schema.sh /docker-entrypoint-initdb.d/ # Allow connections from anywhere. RUN […]

SQL列出引用表中特定列的所有表

我正在使用PostgreSQL,我试图列出所有表中有一个特定的列从一个表作为外键/引用。 可以这样做吗? 我确信这些信息存储在information_schema某处,但我不知道如何开始查询。 谢谢!