Questions tagged [postgresql-9.1]

for PostgreSQL questions specific to version 9.1.

PostgreSQL 9.1 is the version of PostgreSQL released in September of 2011, with expected end-of-life in September of 2016.

While the generic tag should probably be used with all PostgreSQL-related questions, this tag should also be used if the question pertains to features added in version 9.1, or if the question is about a problem seen while running version 9.1.

1821 questions
27
votes
2 answers

Postgresql: auto lowercase text while (or before) inserting to a column

I want to achieve case insensitive uniqueness in a varchar column. But, there is no case insensitive text data type in Postgres. Since original case of text is not important, it will be a good idea to convert all to lowercase/uppercase before…
user1144616
  • 1,201
  • 2
  • 15
  • 16
27
votes
1 answer

How do I reliably determine whether pg_restore succeeded, when success sometimes results in an exit code of 1?

When running pg_restore --clean --dbname=my_database backup_file.sql to restore a database dump to an empty database, the restore succeeds, but with the following warning message: pg_restore: [archiver (db)] Error while PROCESSING TOC: pg_restore:…
Ajedi32
  • 45,670
  • 22
  • 127
  • 172
27
votes
3 answers

Select sum of an array column in PostgreSQL

If I have the following table: Table "users" Column | Type | Modifiers ---------------+------------------+----------- id | integer | monthly_usage | real[] | Where monthly_usage is an array…
Nicolas
  • 2,297
  • 3
  • 28
  • 40
27
votes
6 answers

Hibernate startup very slow

For some reason, the startup of my hibernate application is unbarrably slow. (up to 2 min) I have been thinking that the c3p0 configuration is plain wrong (related question) but studying the logs shows, that there is no activity just after the…
bentrm
  • 1,018
  • 3
  • 10
  • 26
25
votes
4 answers

PostgreSQL - dump each table into a different file

I need to extract SQL files from multiple tables of a PostgreSQL database. This is what I've come up with so far: pg_dump -t 'thr_*' -s dbName -U userName > /home/anik/psqlTest/db_dump.sql However, as you see, all the tables that start with the…
QuestionEverything
  • 4,809
  • 7
  • 42
  • 61
25
votes
4 answers

Dynamically generate columns for crosstab in PostgreSQL

I am trying to create crosstab queries in PostgreSQL such that it automatically generates the crosstab columns instead of hardcoding it. I have written a function that dynamically generates the column list that I need for my crosstab query. The idea…
invinc4u
  • 1,125
  • 3
  • 15
  • 26
24
votes
1 answer

PostgreSQL forces lowercase names?

Just started to learn PostgreSQL 9.1 on linux through C and libpq. For now I check connection, connect, create database, create table and other basic stuff. But I noted that during table creating PQ converts my database name to lowercase. Then I see…
Wine Too
  • 4,515
  • 22
  • 83
  • 137
24
votes
1 answer

Select distinct values with count in PostgreSQL

This is a heavily simplified version of an SQL problem I'm dealing with. Let's say I've got a table of all the cities in the world, like this: country city ------------ Canada Montreal Cuba Havanna China Beijing Canada Victoria China …
durrrutti
  • 1,020
  • 1
  • 8
  • 18
24
votes
4 answers

Cannot make @ManyToOne relationship nullable

I have a many-to-one relationship that I want to be nullable: @ManyToOne(optional = true) @JoinColumn(name = "customer_id", nullable = true) private Customer customer; Unfortunately, JPA keeps setting the column in my database as NOT NULL. Can…
vcattin
  • 687
  • 1
  • 4
  • 15
23
votes
2 answers

Delete all table without dropping database in postgres in django dbshell in one command?

I tried this .. select 'drop table if exists "' || tablename || '" cascade;' from pg_tables where schemaname = 'public'; but doesn't seems to work out for one command?
Irshadmi4
  • 470
  • 1
  • 3
  • 10
23
votes
1 answer

No managed connections available within configured blocking timeout (JBoss 7 and Postgres)

Periodically i get error : ERROR JDBCExceptionReporter --> javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:jboss/datasources/myDB 08:12:05,928 ERROR…
Benjamin
  • 531
  • 2
  • 6
  • 18
22
votes
3 answers

Concurrent db table indexing through alembic script

Is it possible to create concurrent indexes for DB table through alembic script? I'm using postgres DB, and able to create concurrent table indexes through sql command on postgres prompt.(create index concurrently on ();) But couldn't find way to…
user2853625
  • 221
  • 2
  • 4
22
votes
2 answers

How to truncate date in PostgreSQL?

I'm trying to select all transactions in PostgreSQL 9 that happened earlier than the end of the last week. Which date function I should use to build such an interval?
yegor256
  • 102,010
  • 123
  • 446
  • 597
22
votes
3 answers

How to create foreign key only if it doesn't exists already?

I'm using PostgreSQL 9.1. I have a table common.client_contact where I created foreign key using this code: ALTER TABLE common.client_contact ADD FOREIGN KEY (contact_id) REFERENCES common.contact_item(id); If I execute this code, I will get…
Arthur Kalimullin
  • 462
  • 1
  • 5
  • 14
21
votes
2 answers

deadlock in postgres on simple update query

I'm working with postgres 9.1 and getting deadlock exception under excessive execution of a simple update method. According to the logs the deadlock occurs due to execution of two identical updates at the same time. update public.vm_action_info…
moshe
  • 231
  • 1
  • 3
  • 6