0
votes
2answers
85 views

Create an updatable view

I am using postgres9.1 and I have been struggling a lot to find some tutorials on how to create a view which can be later be updated and new rows can be inserted in the view. Can someone give me ...
0
votes
0answers
21 views

Update remote database table with local table using dblink postgresql

How to update remote table records, from a local temporary table, such like this: Local Database: There is a table such as localFruit(id, name, color) Remote Database:there is a table fruits(id, ...
25
votes
1answer
11k views

How do I do an UPSERT (MERGE, INSERT … ON DUPLICATE UPDATE) in PostgreSQL?

A very frequently asked question here is how to do an upsert, which is what MySQL causes INSERT ... ON DUPLICATE UPDATE and the standard supports as part of the MERGE operation. Given that PostgreSQL ...
-2
votes
1answer
58 views

Insert/Update functionality in postgresql [duplicate]

i'm manually updating table in my DB using import functionality in PostgreSQL. Working with large number of data i came across an issue of duplicating primary keys. I am looking for a script to upload ...
0
votes
1answer
70 views

PostgreSQL: Alternative to UPDATE (As COPY to INSERT)

I realize update operation speed in PostgreSQL doesn't meet my expectation especially when I update so many row at the same time, said 10K rows data. Is there any fast alternative to UPDATE? as using ...
0
votes
1answer
36 views

POSGRESQL UPDATE “insert” infront of existing data

UPDATE table SET column = **`insert in front of original data`** WHERE condition Is it possible to insert data in front or at the end? Or it has to be rewritten all over again? Postgresql
4
votes
1answer
1k views

Postgresql - Insert into where not exists using sqlalchemy's INSERT from SELECT

As pointed out here its possible to do the following with postgresql 9.1+ INSERT INTO example_table (id, name) SELECT 1, 'John' WHERE NOT EXISTS ( SELECT id FROM example_table WHERE ...
2
votes
2answers
85 views

Update a table from another table

I am using postgres and I have the following two tables. I would like to update the distinct_network_point table with the altitude value taken from the altitude_of_point table joining them on the id ...
0
votes
1answer
272 views

Update column of a inserted row with with its generated id in a single query

Say I have a table, created as follows: CREATE TABLE test_table (id serial, unique_id varchar(50) primary key, name varchar(50)); test_table ---------- id | unique_id | name In that table, I ...
0
votes
2answers
239 views

Need form to use multiple submit buttons

I have a form that I would like to have display two versions of the data. I know that I can set two variables for this, but I can't figure out how to get it to insert into the postgres db. I have ...
3
votes
2answers
2k views

How to pass string with ' ' (timestamp) in prepared statement?

I am trying to execute the following query INSERT INTO hotspot(timestamp) VALUES (timestamp with time zone '2012-10-25 14:00:00 +05:00' at time zone 'EET'); and i want to pass the timestamp as a ...
0
votes
1answer
145 views

Execute Update Always SET Found to FALSE

I have wrote following trigger. CREATE OR REPLACE FUNCTION tbl_scdr_insert_trigger() RETURNS TRIGGER AS $$ << fk >> DECLARE rowcount int; myrec RECORD; BEGIN EXECUTE 'UPDATE ...
-2
votes
2answers
165 views

Database update

Scenario: I have Database1 (PostgreSQL). For this i) When a record is deleted, the status col. for that record is changed to inactive. ii) When a record is updated, the current record is rendered ...
1
vote
2answers
2k views

PostgreSQL create a new column with values conditioned on other columns

I use PostgreSQL 9.1.2 and I have a basic table as below, where I have the Survival status of an entry as a boolean (Survival) and also in number of days (Survival(Days)). I have manually added a ...
2
votes
1answer
863 views

postgresql way to insert row with “ON CONFLICT” clause semantics

Is there an easy way in postgres to do the equivalent of the following in sqlite? INSERT INTO foo (x, y, z) VALUES (1, 2, 3) ON CONFLICT replace; I've looked around and the solutions I've found are ...
7
votes
2answers
682 views

How does this SQL query to update a row if exists, or insert if not, work?

I'm working with some code. There are several queries whose effect is, if the row exists with some of the data filled in, then that row is updated with the rest of the data, and if the row does not ...