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
21
votes
7 answers

Connection refused (PGError) (postgresql and rails)

I keep getting this error when i try to run my localhost using "$rails s": (Mac OSX 10.8.3) (ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-darwin12.3.0]) (Rails 3.2.11) (psql (PostgreSQL) 9.2.2 ) **installed with homebrew I have been doing a…
21
votes
4 answers

Get interval in milliseconds

I have a procedure that contains code like this: processStart := current_timestamp; -- run statement(s) processEnd := current_timestamp; elapsed := processEnd - processStart; raise notice 'My Statement, elapsed time: %', elapsed; The idea is, I…
Jeremy Holovacs
  • 22,480
  • 33
  • 117
  • 254
21
votes
4 answers

DATE_FORMAT in postgresql

I'm working in postgresql and I need to convert the date format in query itself, in mysql there is option called DATE_FORMAT and I can use a query like this: Select DATE_FORMAT(date_time, '%b %e, %Y, %T') from table_name is there any option in…
Sathish
  • 4,403
  • 7
  • 31
  • 53
20
votes
2 answers

Updating multiple rows with different primary key in one query in PostgreSQL?

I have to update many columns in many rows in PostgreSQL 9.1. I'm currently doing it with many different UPDATE queries, each one that works on a different row (based on the primary key): UPDATE mytable SET column_a = 12, column_b = 6 WHERE id =…
Amandasaurus
  • 58,203
  • 71
  • 188
  • 248
20
votes
3 answers

Select date (timestamp) from PostgreSQL as string (char), beware of NULL value

I want to select a date (my column is a timestamp type). But when in column is a NULL date, I want to return an empty string. How to do this? I wrote this: SELECT CASE WHEN to_char(last_post, 'MM-DD-YYYY HH24:MI:SS') IS NULL THEN '' ELSE…
Katie
  • 3,517
  • 11
  • 36
  • 49
20
votes
1 answer

Most efficient way to retrieve a unique list of keys from all rows of an hstore?

For simplicity sake, say I have a table with a single column that is just an hstore. What is the most efficient way to go about getting a unqiue list of all the keys from all rows of the…
jay.lee
  • 19,388
  • 8
  • 39
  • 38
19
votes
2 answers

Postgres SELECT* FROM table WHERE column-varchar=="string-example"?

I have the following table: CREATE TABLE lawyer ( id SERIAL PRIMARY KEY, name VARCHAR NOT NULL UNIQUE, name_url VARCHAR check(translate(name_url, 'abcdefghijklmnopqrstuvwxyz-', '') = '') NOT NULL UNIQUE ); I want to SELECT * FROM lawyer where…
Jeka
  • 1,600
  • 3
  • 22
  • 36
19
votes
2 answers

PostgreSQL: How to list all available datatypes?

Question: In PostgreSQL (using SQL, not the console), how can I list all available datataypes ? Ideally like this: http://www.java2s.com/Code/PostgreSQL/Postgre-SQL/Displaysalldatatypesintheconnecteddatabasewithcomments.htm It should also list user…
Stefan Steiger
  • 78,642
  • 66
  • 377
  • 442
18
votes
2 answers

How to do Pivoting in PostgreSQL

I am new to PostgreSQL. Suppose I have a table as under colorname Hexa rgb rgbvalue Violet #8B00FF r 139 Violet #8B00FF g 0 Violet #8B00FF b 255 Indigo #4B0082 r 75 Indigo #4B0082 g 0 Indigo #4B0082 b 130 Blue #0000FF r …
priyanka.sarkar
  • 25,766
  • 43
  • 127
  • 173
18
votes
3 answers

PostgreSQL- ModuleNotFoundError: No module named 'psycopg2'

I can confirm psycopg2 is install (using conda install -c anaconda psycopg2) but the it seems psycopg2 cannot be imported to my python script or the interpreter is unable to locate it. I also tried installing using pip3, requirements are satisfied,…
arilwan
  • 3,374
  • 5
  • 26
  • 62
18
votes
2 answers

postgres hstore exists and doesn't exist at same time

I set up a Rails app on a remote server and created an hstore extension sudo -u postgres psql CREATE EXTENSION hstore; I then deployed an iteration of the app that uses hstore in one of the postgres tables, but when it ran the migrations it gave…
Tomoko Yamaguchi
  • 487
  • 1
  • 6
  • 21
17
votes
3 answers

Spring Security JDBC authentication default schema error when using PostgreSQL

Is it really impossible to use default schema for Spring Security with PostgreSQL, because the part "varchar_ignorecase" does not exist can't be replaced? I'm just testing the default settings: auth.jdbcAuthentication() …
ikhsan
  • 800
  • 5
  • 11
17
votes
2 answers

How are import statements in plpython handled?

I have a plypython function which does some json magic. For this it obviously imports the json library. Is the import called on every call to the function? Are there any performance implication I have to be aware of?
Mauli
  • 16,863
  • 27
  • 87
  • 114
16
votes
3 answers

PostgreSQL with-delete "relation does not exists"

I am using postgreSQL 9.1 and I want to delete duplicates from my table using this tip: https://stackoverflow.com/a/3822833/2239537 So, my query looks like that: WITH cte AS (SELECT ROW_NUMBER() OVER (PARTITION BY code, card_id, parent_id …
Alex Kartishev
  • 1,836
  • 3
  • 18
  • 25
16
votes
2 answers

Postgres function returning table not returning data in columns

I have a Postgres function which is returning a table: CREATE OR REPLACE FUNCTION testFunction() RETURNS TABLE(a int, b int) AS $BODY$ DECLARE a int DEFAULT 0; DECLARE b int DEFAULT 0; BEGIN CREATE TABLE tempTable AS SELECT a, b; RETURN QUERY SELECT…
Satish Sharma
  • 3,284
  • 9
  • 38
  • 51