UPDATE changes the values of the specified columns in all rows that satisfy the condition. Only the columns to be modified need be mentioned in the SET clause; columns not explicitly modified retain their previous values.

learn more… | top users | synonyms

1
vote
1answer
5 views

SQL - Update table for a unique ID with multiple entries if one entry has variable in question

I'm trying to update a table to fill in a variable to each row in the table if one row for the unique ID shows that variable. I was trying to do the following, but it's giving me an error. ...
1
vote
1answer
22 views

Does a database update force index rebuild regardless of updated field?

With MySQL (InnoDB), I understand that having indexes slow down UPDATE queries. I would like to know if this happens regardless of what fields are updated. For example, if I have a table with 20 ...
0
votes
2answers
58 views

How to update a column with values from the same newly inserted row on a SQL Server 2014 trigger?

Using SQL Server 2014, I have this: Table1 Tab1_id int identity(1,1) primary key Tab1_val1 smallint Tab1_val2 smallint Tab1_valInfo varchar(10) -- not yet implemented, will be used ...
5
votes
2answers
134 views
+50

Is this update, select combination query thread safe?

I have a table called seats, which has a schema like this id,taken For each user, I take a random untaken id and assign to that user, here for simplicity say, I make taken =1. The query I am ...
0
votes
2answers
34 views

Can I update only the needed changes in a database?

First of all, I apologize if you can't understand very well what I am saying and it can be edit for better understanding of my post. The next example is for better understanding of databases with ...
0
votes
1answer
42 views

Store the resulting list of a SELECT in a variable to count AND use the result

I have stored procedure that uses a cursor and for every fetch a duplicate SELECT, once to determine the number of IDs found (SELECT COUNT(ID) FROM TableA WHERE something.. @cur_var) and if the ...
0
votes
1answer
28 views

Updating MySQL innodb table based on multiple joins

I have a table with the following (slightly simplified) structure CREATE TABLE `oak_relation` ( `o_id` int(10) unsigned NOT NULL, `k_id` bigint(20) unsigned NOT NULL, `initial` float unsigned NOT ...
2
votes
0answers
36 views

How to optimize update using join in postgresql

I'm using PostgreSQL 9.3.5 on a CentOS system. I have a very large table (twenty million rows, 50+ column) that aggregates data from a few hundred systems. Several times a day each of the systems ...
0
votes
1answer
14 views

MySQL: Is there a way to update a field so that all foreign key related fields are updated as well?

I'm assuming the answer to this question is yes but it is hard to Google this type of question and not get overly ambiguous results. I am working with a database that was dumped from a Magento ...
0
votes
0answers
35 views

Update on table deletes the record

I'm having a problem in my oracle database, I have a table PAYMENTS which has an ID (PK) and when I want to update a record: UPDATE PAYMENTS SET AMOUNT = 2000 WHERE ID = '1'; The record with ID = ...
1
vote
1answer
50 views

Set bit in Table A if values are present in Table B

I have two tables, Containing up to ~10 million entries. TableA which has 3 columns: IDA (bigint), IDB (int) and CHK (bit). (IDA, IDB) is the primary key. TableB which has 2 columns: IDA (bigint), ...
0
votes
2answers
44 views

How To Ignore SQL Update Notification

I have a very weird situation. One of our SQL Servers has a software update notification pending for Microsoft SQL Server 2008 R2 Service Pack 1 (KB2528583). However, this server is already at SP2. ...
0
votes
1answer
20 views

Postgres blocking UPDATE on new column?

For the life of me, I can't figure out why Postgres won't let me issue this update statement below. Assume any table called dim_dates where there's a column dateType: ALTER TABLE dim_dates DROP ...
0
votes
1answer
28 views

MySQL update one table from another joined many-to-many

I have two tables, events and plays joined many-to-many by a third table plays_in_events. Where the events.Name field is blank, I want to set it equal to the name of the play that was performed in ...
0
votes
1answer
26 views

postgresql updating integer column taking more space than expected

I have two tables, A(a1 serial, a2 varchar(8)) and B(b2 varchar(8)); My query looks like, alter table B add column b1 integer; update B t1 set b1 = t2.a1 from (select b1, b2 from B) t2 where t1.a2 = ...
5
votes
1answer
99 views

.WRITE clause performance optimization

I have found that you can do high performance updates on varchar(max),nvarchar(max),varbinary(max) columns using the .WRITE clause(example here and here). Unfortunately, there is nothing mentioned ...
-1
votes
1answer
37 views

Is there a way to copy/initialize values in a set

What I want to do (I know this does not work) is: update stats set BandwidthLastMonth = BandwidthThisMonth, BandwidthThisMonth=0 where myPk = 3 Is there a way to do this in a select ...
0
votes
1answer
33 views

Is it possible to modify an existing trigger definition in MySQL?

I am wondering if it is possible to update a trigger definition in MySQL. For example, I have a trigger T and I want to add some new functionality to it. My assumption is that I need to drop and ...
0
votes
2answers
30 views

Updating a table with a single UPDATE statement vs several UPDATE statements

CREATE TABLE `messages` ( `mes_id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT COMMENT 'номер объявления', `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'дата/время дачи/изменения ...
0
votes
1answer
46 views

Check for blocked queries periodically and cancel them

I have series of update queries which are executed every 5-10 seconds. Sometimes it happens that one of these will block all the pending update queries as for some reason it just freezes. Since I can ...
0
votes
0answers
17 views

Does storing page views in my page table slow performance?

I am storing page views in a view_countcolumn on my page table. So every time the page gets loaded I increment the view count and update the entry. What affect can this have on the performance of my ...
0
votes
0answers
38 views

What is the best way to execute a MySQL script periodically on Linux

I want to execute some SQL everyday in a Linux server using MySQL to UPDATE some column's values. In order to do that I use the UPDATE ... SET ... WHERE ... statement. I want to know which is the ...
2
votes
0answers
38 views

Unable to Update on SQL Server 2008 R2

This is a bit strange so bear with me please. After installing a new SQL Server 2008 R2 on a new server (Windows 2012 Standard) just like the production one, I tried to connect my web aplication ...
2
votes
1answer
29 views

Translate SQL Server update statement to MySQL

I have a development environment with MySQL and a production environment with SQL Server. This update statement works with SQL Server: UPDATE THIS SET <list_of_column_assignments> FROM ...
1
vote
1answer
41 views

Delete rows while updating references

Suppose I have a person table with an id and some other columns. Other tables reference the person table using ON UPDATE CASCADE. for instance: CREATE TABLE person (id int PRIMARY KEY); CREATE TABLE ...
1
vote
3answers
139 views

Undo SQL UPDATE Azure DB

I have accidentally updated over 3,000 records in one of my tables hosted on Azure. This was not a transaction and I did not have any back ups for this table. I've read around and found ApexSQL Log ...
2
votes
1answer
78 views

Most efficient way to do many UPDATES in Postgresql

I have to update cca 2.5 milion rows in a table with cca 20 milion rows. The updated column value is based on value of another column, but another select is required to determine it's value. The ...
2
votes
2answers
57 views

How do you update a large MySQL table that's on a server?

I have an application on a web server. The PHP front end for the application queries a MySQL database which has a table that contains 60 million taken domain names. My application queries this ...
0
votes
1answer
23 views

Update table inner join

I have two tables and i need to update one of them with respect to the id's of the second table first table success log Id pid shiftid 1 2 2 2 3 2 ...
0
votes
0answers
21 views

long mysql insert and update script user variables appear to be lost while running script

I have a mysql database table called 'dash_something' dash_something ------------- date, DATE *this is the date of the summary type, CHAR(10) entity, CHAR(25) number_of_emails_1, INT ...
0
votes
0answers
37 views

Update existing (old) rows vs delete and insert when needed

I'm building a database system that needs to store login tokens for a system that validates if a users login token is valid or outdated. The table is pretty simple UserID int Primary Key LoginToken ...
1
vote
1answer
70 views

Joins in Update statement in sqlite

CREATE TABLE Table_1 ( Id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , EmailId VARCHAR ) INSERT INTO Table_1 VALUES (1,'raj@gmail.com'); INSERT INTO Table_1 VALUES (3,'test@gmail.com'); ...
0
votes
1answer
65 views

Update table from different table

UPDATE RBI.RBI_OV_F_DETAIL A SET (BRANCH_ID, BRANCH_NUMBER) = ( SELECT PRICE_BRANCH_ID, PRICE_BRANCH FROM RSE.RSE_SO_F_ORDERS B WHERE A.SOURCE_ID = ...
0
votes
1answer
72 views

MySQL add few column exception for TRIGGER UPDATE FOR EACH ROW

How to effectively add column id, name exception for trigger: CREATE TRIGGER updated BEFORE UPDATE ON table1 FOR EACH ROW SET NEW.date=NOW() so that date=NOW() will be affected on updating any ...
1
vote
1answer
55 views

Update different columns on different clauses

I have a database table in Postgres 9.3 with the following layout: id SERIAL, col1 INT, col2 INT Whenever a new row is inserted, I will have to update ALL rows col1 and/or col2 in different cases ...
1
vote
1answer
32 views

Optimizing bulk update performance in Postgresql with dependencies

Basically my question is the same as this one, but WITH dependencies, so drop/renaming the table is not a trivial option (I assume). We are refactoring a large, poorly designed table which has many ...
3
votes
1answer
34 views

Why does the behavior of array syntax differ from '(?,?)' syntax when updating a point field and that field is NULL?

I'm using PostgreSQL 9.3.5. Suppose I have the following table: CREATE TEMPORARY TABLE point_test ("name" varchar(255), "pt" point); I then insert a row, leaving pt NULL: INSERT INTO point_test ...
0
votes
0answers
38 views

Bulk update performance

I have a several process that aggregate some statistics on items (how much was shown, clicked ... around 30 factors). Once in a 5 minutes i flush the aggregate data to postgres (9.1). I have 250K ...
1
vote
0answers
60 views

Update on a small table times out

We use Microsoft SQL Server Express Edition with Advanced Services 2008 R2 SP2 We have two locations. Each location has one sql server that serves about 20 client computers. Client computers are ...
2
votes
2answers
113 views

Update on view over partitioned tables updating all indexes

We have a table, which is partitioned through a date field into separate years. There is a view over all of these tables (Call) Schema is as follows: CREATE TABLE [dbo].[Call_2015]( [calID] ...
0
votes
0answers
121 views

Updating +150,000 rows using .sql file causes ERROR 2013 Lost connection to MySQL server during query

I am using ubuntu 12.04. I have a .sql file that is around 5 megabytes. When I use the command: mysql -u -p -v database query.sql The server prints out the content of the file (because of --verbose) ...
5
votes
2answers
162 views

Adding a sequence number to existing rows

I have a table with an OrderSequence column. The schema looks roughly like this: id Name OrderSequence I have an array of ids ["1", "2", "3", "4"] from an application, and I want to set the ...
0
votes
1answer
43 views

Trigger on a Schema

Is it possible to create a Trigger on a Schema? I have to audit the changes on my tables. But I have a lot of tables and I don't one to create a trigger on them one by one. --Database level trigger. ...
0
votes
1answer
15 views

How to minimize the writes needed to update a counter field multiple times

I need to minimize the number of queries that are executed just for updating a counter field. One of my example counter fields is raised by 1 everytime a page is visited, I was wondering what could ...
1
vote
1answer
89 views

Improve performance on concurrent UPDATEs for a timestamp column in Postgres

I am using a timestamp column called updated_at for cache invalidation. More information on this particular technique here. The queries all have the same format UPDATE "managers" SET "updated_at" = ...
0
votes
1answer
68 views

MySQL Update Multiple Rows in Large Table

I have a large InnoDB MySQL database table. I would like to run this query against the database table: Update myBigTable Set someColumn=x WHERE userId = 7 OR userId = 88 OR userId = 22 OR userId = ...
0
votes
2answers
30 views

How can I maintain old information after an update?

I am having an issue figuring out a solution to not lose old information. For example, customers can place many orders. Let's a customer, Mary, makes her 1st order in 2013. Fast-forward to 2014, ...
0
votes
2answers
445 views

MySQL ON DUPLICATE KEY UPDATE performance issue

We have a table with over 200k rows. Every row belongs to a category, there are almost 50k rows per category. What is the best way to update all rows of that category? We are using a script like ...
1
vote
1answer
46 views

How to update a single record in a table based of foriegn key ID in another table?

I am still very new to sql. I am having troubles updating one table. I am sending information from a web application into Microsoft SQL 2008 database. I have a table called EmployeePermissions that ...
2
votes
1answer
192 views

Create a new table (multiple columns) by selecting random values from an existing table

I am stuck on the following task (PostgreSQL 9.3). Let's say we have the following table1 (which has 10k rows): table1: id 754 800 330 4 59 My goal is to create another table2 with two columns ...