Quantcast
Channel: Question and Answer » postgresql
Browsing all 1138 articles
Browse latest View live

Syntax error at or near “1”— PostGIS in Action — Chapter 11 SQL data dump

I’m following along with PostGIS in Action, 2nd ed., chapter 11, while attempting the SQL dump from the data files and I’m getting the following error: ERROR: syntax error at or near "1" LINE 189: 1...

View Article


Postgres query to return JSON object keys as array

Is it possible to return a JSON object keys as an array of values in PostgreSQL? In JavaScript, this would simply be Object.keys(obj), which returns an array of strings. For example, if I have a table...

View Article


Avoid double query on the same table

I have two queries which are doing basically the same thing, but have different grouping, the first query (query 1) is used to populate a chart, and the second to populate a table. Query 1: SELECT...

View Article

How to use SSL/TLS between server and client with Postgres?

I don’t know much with it comes to security. I’m deploying a virtual machine with my database in a cloud service. I would like to encrypt all the communication between this server and any clients. How...

View Article

DENY insert,update,delete to user (PostgreSQL)

I wonder if Postgres support the DENY command. I search in the documentation but I couldn’t find anything about deny. I have GRANT ALL ON table1 TO user1 WITH GRANT OPTION but I don’t want user1 to be...

View Article


select/union output from two columns into three

I’m sure there is an easy answer to this, but my PostgreSQL isn’t up to it at the moment. I have a table hostname_facts with three columns: hostname name value hostname is a list of fully-qualified...

View Article

PostgreSql : flatten json array data

From my current query, I obtain this jsonb data : values: "a1", ["b1", "b2"] And I want to flatten it on one level only, like this : values: "a1", "b1", "b2" Here is a simplfied way to get data in a...

View Article

GeoServer Sql view setup error?

The problem goes like this: I am trying to route osm data with the help of this tutorial: (http://workshop.pgrouting.org) but in the step where I create the sql view and add the parameters it fails to...

View Article


osm2pgsql password prblem

I’m totally new in PostgreSQL. I followed this guide to set up Postgre and Postgis: http://learnosm.org/it/osm-data/setting-up-postgresql/ I created an OSM database and the Postgis extension. I tried...

View Article


Image may be NSFW.
Clik here to view.

ID duplicates where none should exist in postgresql

I have to do an assignment with the StackExchange database. I get the error shown in the picture.

View Article

PostgreSQL 9.4: Index Only Used For Lower INET Ranges

For some reason queries on the high range of are extremely slow and queries on the low range are extremely fast. My index is an adapted version of the answer in Optimizing queries on a range of...

View Article

Image may be NSFW.
Clik here to view.

Why are correlated subqueries sometimes faster than joins in Postgres?

This relates to the dataset described in Postgres is performing sequential scan instead of index scan I’ve started work on adapting the import logic to work with a more normalised schema – no surprises...

View Article

psql variable holding text with multiple lines

This works as expected, set x '''2n3''' but this doesn’t set x '''2 3''' Is there a workaround for later example so I don’t have to use n instead of newline?

View Article


Debian Server failover setup

I need to set up two servers with failover capability (Active – Passive model) sharing a common DB (Postgres)running over NAS. Could you please suggest me some workaround for the same ?

View Article

psycopg2 – drawbacks of reusing cursors?

I am new to Python and the psycopg2 module. context Working on a script that select data from MySQL, perform some operations (conversion of data-types and other “transformations”), and finally insert...

View Article


Why am I getting old data?

Today I discovered something weird on PostgreSQL 9.5. (I have no idea whether this is because of beta or not.) When I want to fetch data, I get old and deleted data from query. I then do VACUUM FULL...

View Article

PostgreSQL: access right problems

I have a “production” user and database on which I want to give right access on all the users belonging to a production group. Unfortunately, I don’t succeed, keeping the access denied error. Can you...

View Article


CREATE DATABASE … WITH TEMPLATE seems to lose relations in PostgreSQL

I’m trying to Create a copy of a database in postgresql per the SO answer from 2009, but running into problems. In Postgres 9.3.9, this creates a database with no relations (the gcis db exists and has...

View Article

How autocommit = 1 impacts statements between BEGIN/COMMIT?

Let’s say I have following code: begin; set autocommit = 1; update tbl1 set col1 = 1; update tbl1 set col1 = 2; commit; What would be the difference if autocommit (line 2) was set to 0?

View Article

How to return a set of rows from this function?

I am new to Postgres functions and have a table with the following structure: CREATE TABLE options.options ( delta double precision, gamma double precision, rho double precision, theta double...

View Article
Browsing all 1138 articles
Browse latest View live