sql-update

Oracle SQL Update query takes days to update

妖精的绣舞 提交于 2019-12-24 16:22:17
问题 I am trying to update a record in the target table based on the record coming in from source. For instance, if the incoming record is present in the target table I would update them in the target else I would simply insert. I have over one million records in my source while my target has 46 million records. The target table is partitioned based on calendar key. I implement this whole logic using Informatica. I find that the Informatica code is perfectly fine looking at the Informatica session

Copy Data To Existing Rows Within Same Table in SQL Server

房东的猫 提交于 2019-12-24 15:27:21
问题 In SQL Server 2008, I want to update some of the rows with data from another row. For example, given the sample data below: ID | NAME | PRICE --------------------------------------- 1 | Yellow Widget | 2.99 2 | Red Widget | 4.99 3 | Green Widget | 4.99 4 | Blue Widget | 6.99 5 | Purple Widget | 1.99 6 | Orange Widget | 5.99 I want to update rows with ID 2, 3, and 5 to have the price of row 4. I found a nice solution to update a single row at Update the same table in SQL Server that basically

Sequel gem increment

瘦欲@ 提交于 2019-12-24 14:26:04
问题 I am trying to use the Ruby Sequel gem for DB operations. I am stuck for incrementing and decrementing values. The doc says that this should work, even though it seems very strange for me to be able to add a number and a symbol. 2.0.0-p247 :019 > require 'sequel' => true 2.0.0-p247 :020 > s = Sequel.connect('sqlite://db.sqlite') => #<Sequel::SQLite::Database: "sqlite://db.sqlite"> 2.0.0-p247 :021 > s[:query_volume].update_sql(:queries => 3) => "UPDATE `query_volume` SET `queries` = 3" 2.0.0

Reference a column and update it in the same statement

我是研究僧i 提交于 2019-12-24 13:28:38
问题 I have a table that I need to move a value from one column to another then set a new value in the original column. declare @foo table (A int, B int); insert into @Foo select 1, 0; update @Foo set B = A, A = 2; After the update does B always contain 1 or is this non deterministic behavior and it will sometimes have a value of 2 due to A being updated first (and all my tests have just never hit just right the conditions to have it be 2 )? As a followup question if the answer is " B will always

How to manually lock and unlock a row?

不羁岁月 提交于 2019-12-24 13:27:50
问题 I am trying to circumvent double-writes by locking and unlocking certain rows. I have a table personnel and as soon as a user tries to edit a row, I want to lock that row. So BEGIN; // I guess I have to lock it somehow here SELECT * FROM personnel WHERE id = 12; COMMIT; and once an edit as been made, I want to submit the UPDATE in the same style: BEGIN; //Unlocking UPDATE personnel SET ... WHERE id = 12; COMMIT; In the time between, when another user tries to edit the same row, he would get a

SQL Anywhere Error -728: Update operation attempted on non-updatable remote query

穿精又带淫゛_ 提交于 2019-12-24 12:54:57
问题 What I'm trying to do: update table_name set field2 = substring(REGEXP_SUBSTR(field1, 'item=[0-9]+', charindex('item=', field1)), 6) But I'm getting SQL Anywhere Error -728: Update operation attempted on non-updatable remote query Can I solve it somehow? I don't use local/remote tables. I use one table. 回答1: So I guess I found soltion... even 2. Unfortunately still no way to use REGEXP_SUBSTR... I do: first alter table my_table add item_position int null alter table my_table add is_char int

Messed up SQL data - Select within update statement

橙三吉。 提交于 2019-12-24 12:41:00
问题 I accidentally ran a query twice and all the points in my database have messed up (3000 records). Top 4 for each result has fixed results but points between last and 5th are calculated (Last is 100pts). Click here for more info I essentially need this statement converting to SQL: Points = 100 + ((100 / (NumberOfResults - 4)) * (NumberOfResults - PositionOfResult)) How can I get a select statement to refer to the Select and the Update table separately. This doesn't work: UPDATE Results R1 SET

Oracle UPDATE performance issue and optimization

点点圈 提交于 2019-12-24 10:28:11
问题 Let's take a query I had a lot of problems with. The table *CONF_ELEMENTI_FATTURABILI* is 160 Gb large and is partitioned on the edw_partition field in 2587 partitions (but parallelism does not work in the second query). *BCK_MEM_ANIMALI_F_ROPT_ELF* and *INT_TEMP51* are very similar. They have indexes and contains 90k record (the second is the GROUP BY of the first one). The update is based on the PK. So exactly 90k records are updated. In 30' the following update query does not end. How can

SQL Query to fill column with combination of other columns

让人想犯罪 __ 提交于 2019-12-24 09:26:57
问题 I have table with this structure ID | Parameter1 | Parameter 2 | Multiplication 1 | 1024 | 100 | 2 | 1200 | 200 | 3 | 1600 | 300 | 4 | 1900 | 400 | I want to fill column Multiplication with combined string from Parameter 1 and Parameter 2 ID | Parameter1 | Parameter 2 | Multiplication 1 | 1024 | 100 | 1024_100 2 | 1200 | 200 | 1200_200 3 | 1600 | 300 | 1600_300 4 | 1900 | 400 | 1900_400 Help me please to create this SQLQuery 回答1: Using SQL then the following query should work.. Assuming the

Means to UPDATE WHERE Value is IN Subquery that has GROUP BY so no Race-Condition Issue(s)?

∥☆過路亽.° 提交于 2019-12-24 09:25:22
问题 Perhaps it's my naiveté, perhaps my paranoia, but I think I'm looking for a solution to a race-condition issue that seems like it should be so common there'd be floods of solutions and I'd've found one by now... but I haven't. The simplistic scenario is I have a process that's supposed to grab any records where there are more than one of a certain type. I'd like to make the system/process(es) thread-/multiprocessing-/reentrant-/buzzword-of-the-day-safe; if the same process gets started and