Skip to main content

Questions tagged [upsert]

UPSERT: SQL-UPDATE a row, or if not found INSERT a new row.

1 vote
2 answers
99 views

I'm tuning the server in order to speed up several SQL queries generated by a product and that can't be modified or tuned themselves. I'm stuck on a query that creates a CTO an then an INSERT / SELECT ...
Ivan Rododendro's user avatar
5 votes
2 answers
842 views

This classic concurrency safety article is clearly designed for only upserting one row at a time. In my situation, I have a table-valued input and I want to upsert each row in a concurrency safe way. ...
J. Mini's user avatar
  • 1,342
-1 votes
1 answer
322 views

I need to upsert data to a PostgreSQL database from a high traffic application which needs to be optimized for write performance. The different rows to upsert in a batch will have values for different ...
hubbabubba's user avatar
0 votes
1 answer
339 views

CREATE TABLE SourceProducts( ProductID INT, ProductName VARCHAR(50), Price DECIMAL(9,2) ) GO INSERT INTO SourceProducts(ProductID,ProductName, Price) VALUES(1,'...
amit agarwal's user avatar
3 votes
1 answer
4k views

Suppose we have the following table: CREATE TABLE names( id SERIAL NOT NULL, CONSTRAINT names__pk PRIMARY KEY(id), name TEXT NOT NULL, CONSTRAINT names__name__unq UNIQUE(name) ); INSERT INTO names(...
user14381362's user avatar
1 vote
1 answer
1k views

I have a table with columns 'id', 'a', 'b, 'c', 'd'. Also, I have a unique constraint on ('a', 'b', 'c', 'd') so no entries can be added where all those fields are the same. I want to upsert entries e....
kichma's user avatar
  • 13
1 vote
1 answer
164 views

This is a very common problem, faced by virtually every DBA who has to responsibilities to both application and BI teams. Consider the following: You have two T-SQL servers, Production and Reporting. ...
J. Mini's user avatar
  • 1,342
0 votes
1 answer
230 views

Consider the following upsert, run in a trigger: INSERT INTO current_scores (user_id, score, updated_at) VALUES (NEW.user_id, NEW.score, NEW.inserted_at) ON CONFLICT (user_id) DO UPDATE SET ...
Nathan Long's user avatar
  • 1,025
0 votes
1 answer
990 views

I have a trigger like BEFORE INSERT ON table_a FOR EACH ROW EXECUTE FUNCTION upsert_into_table_b(). If I execute a bulk insert like INSERT INTO table_a ([columns]) VALUES ([row 1 values]), ([row 2 ...
Nathan Long's user avatar
  • 1,025
0 votes
1 answer
533 views

The docs on INSERT say: If an index_predicate is specified, it must, as a further requirement for inference, satisfy arbiter indexes. Note that this means a non-partial unique index (a unique index ...
Nathan Long's user avatar
  • 1,025
0 votes
0 answers
159 views

I'm trying to use SQLite's upsert syntax as described in their documentation However I get the following error, in both WebSql (SQLite v3.41.2) and SQLite on Android (SQLite v3.40.0) could not prepare ...
Eriedor's user avatar
  • 51
1 vote
0 answers
679 views

With this table definition: create table t1 ( id uuid not null primary key, "u1" integer not null references u, "p1" integer not null references p, "c1" ...
Slim's user avatar
  • 291
-1 votes
1 answer
1k views

I have a table with a deleted_at column, see comment. The deleted_at column behaves like a one-way boolean event flag, i.e. once a row is deleted it can't be restored. There is also an asynchronous ...
mozey's user avatar
  • 99
0 votes
1 answer
91 views

Here, a lot of energy seems spent on Coalesce - I think it is to avoid the case where a null value in the update record could overwrite a non-null value. Say we have a table of businesses and some ...
Ken Lyle's user avatar
1 vote
2 answers
1k views

I have two tables: CREATE TABLE est ( est_id serial PRIMARY KEY , est_nom varchar(70) ); CREATE TABLE bm ( id serial PRIMARY KEY , est_nom int , nom varchar(70) , CONSTRAINT FK_bm_est FOREIGN KEY(...
David Palacios's user avatar

15 30 50 per page
1
2 3 4 5
8