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
15
votes
4 answers

How do I install pgcrypto in postgresql 9.1 on Windows?

The web page for Postgresql says that pgcrypto is included in the download for Postgresql 9.1. There is no pgcrypto.sql file, however. If I look in the share\extension directory there are 3…
Dean Schulze
  • 9,633
  • 24
  • 100
  • 165
15
votes
2 answers

Postgres Aggregating conditional sum

I am trying to sum-aggregate conditional products for total weight of an order (I hope that makes sense). I get error: ERROR: aggregate function calls cannot be nested LINE 6: , SUM ( CASE WHEN pc.type = 'TEES' THEN (SUM…
user2670949
  • 163
  • 1
  • 2
  • 7
15
votes
4 answers

Alter a Column Data Type Postgres

Hey I have just started working on PostgreSQL, and I am wondering how can we change a column's data type, I tried the following command: alter table tableName alter column columnName type timestamp with time zone; However I got the following…
user2597012
  • 581
  • 4
  • 9
  • 28
15
votes
3 answers

Get a timestamp from concatenating day and time columns

I am having day and time fields in database. I want to get the time-stamp by concatenating the day and time. How to do this in PostgreSQL? I have done this: SELECT EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28'); And it is working fine. But…
Yasitha
  • 2,233
  • 4
  • 24
  • 36
15
votes
7 answers

Integration of postgreSQL on WAMP

I have just installed the postgreSQL on windows 7. I am trying to integrate postgreSQL with WAMP server. For this i have done the following changes in httpd.conf and php.ini file 1 LoadModule c:/path to libpq.dll in httpd.conf and then 2…
Ammar Hayder Khan
  • 1,287
  • 4
  • 22
  • 49
15
votes
2 answers

Constraint defined DEFERRABLE INITIALLY IMMEDIATE is still DEFERRED?

In connection with this answer I stumbled upon a phenomenon I cannot explain. Version: PostgreSQL 9.1.2 on x86_64-unknown-linux-gnu, compiled by gcc-4.4.real (Debian 4.4.5-8) 4.4.5, 64-bit Testbed: CREATE TEMP TABLE t ( id integer , txt text ,…
Erwin Brandstetter
  • 605,456
  • 145
  • 1,078
  • 1,228
14
votes
4 answers

Check if NULL exists in Postgres array

Similar to this question, how can I find if a NULL value exists in an array? Here are some attempts. SELECT num, ar, expected, ar @> ARRAY[NULL]::int[] AS test1, NULL = ANY (ar) AS test2, array_to_string(ar, ', ') <> array_to_string(ar, ', ',…
Mike T
  • 41,085
  • 18
  • 152
  • 203
14
votes
5 answers

postgresql: Converting bytea to bigint

I have to convert a bytea entry for a query to bigint. How could this be done? More Info: I have a hibernate repository as below - @Query(value = "update Sample_Table set other_id = ?1 where id = ?2", nativeQuery = true) void…
Manish Shukla
  • 163
  • 1
  • 1
  • 7
14
votes
1 answer

Why would ALTER TABLE DROP CONSTRAINT on an empty table take a long time?

I am trying to load several million rows of data into a table (a "follow" table that contains two foreign keys to the user table, and the associated indexes on those keys) in a single transaction. My initial attempt caused my script to crash…
Andrew Gorcester
  • 19,595
  • 7
  • 57
  • 73
14
votes
3 answers

List constraints for all tables with different owners in PostgreSQL

Do I have to be owner of relation to access constraint related data in information schema? I've tested the following and it seems that I have to be the owner. create schema rights_test; create table rights_test.t1 (id int primary key); create table…
Tomas Greif
  • 21,685
  • 23
  • 106
  • 155
14
votes
1 answer

Create database, tables etc in one script postgresql

I've a script: CREATE DATABASE ahop GO CREATE TABLE shop.dbo.TABLE1 ( ); CREATE TABLE shop.dbo.TABLEN ( ); But it doesn't seem to work in PostgreSQL. Error message: "error near GO". I dont get it, how to create scripts in Postgresql?
Ariel Grabijas
  • 1,472
  • 5
  • 25
  • 45
14
votes
1 answer

Join a count query on generate_series() and retrieve Null values as '0'

I want to count ID's per month using generate_series(). This query works in PostgreSQL 9.1: SELECT (to_char(serie,'yyyy-mm')) AS year, sum(amount)::int AS eintraege FROM ( SELECT COUNT(mytable.id) as amount, …
zehpunktbarron
  • 1,193
  • 3
  • 15
  • 26
14
votes
3 answers

Getting name of the current function inside of the function with plpgsql

Is there anyway from within a plpgsql function that you can get the name of the function? Or even the OID of the function? I know there are some "special" variables (such as FOUND) within plpgsql, but there doesn't seem to be any way of getting…
David S
  • 12,967
  • 12
  • 55
  • 93
14
votes
3 answers

PL/pgSQL SELECT into an array

Here's my function declaration and part of the body: CREATE OR REPLACE FUNCTION access_update() RETURNS void AS $$ DECLARE team_ids bigint[]; BEGIN SELECT INTO team_ids "team_id" FROM "tmp_team_list"; UPDATE "team_prsnl" SET…
nnyby
  • 4,748
  • 10
  • 49
  • 105
14
votes
4 answers

How to clone a test database from a production one in one single action?

I am looking for a basic script/command that will create a copy of a live database (let name them mydb and mydb_test, both on the same server). Requirements it has to run even if the mydb_test already exists and have records it has to work even if…
sorin
  • 161,544
  • 178
  • 535
  • 806