sql-update

Auto incremental date field and version oracle sql for a table

扶醉桌前 提交于 2021-02-11 07:08:19
问题 I have a table and in this table i have data is not properly loaded data integrity issue ,since this is a dimension table we need to maintain the effective_dt_from and effective_dt_to and version correctly ,below is the table and sample data create table TEST ( LOC_SID NUMBER(38,0), CITY VARCHAR2(180 BYTE), POSTAL_CD VARCHAR2(15 BYTE), EFFECTIVE_DT_FROM DATE, EFFECTIVE_DT_TO DATE, VERSION NUMBER(38,0) ); Insert into TEST values (81910,'chicago',null,to_date('01.01.00 00:00:00','DD.MM.YY HH24

MySQL: Update multiple columns if their value equals to [duplicate]

核能气质少年 提交于 2021-02-10 12:13:31
问题 This question already has answers here : MySQL - UPDATE multiple rows with different values in one query (7 answers) Closed 10 days ago . I would like to know if there's a 'short' way (single query) to update certain columns, if their value equals to an integer. Let's say that my table looks like this: +------------+----+----+----+----+ | customerID | v0 | v1 | v2 | v3 | +------------+----+----+----+----+ | 1 | 3 | 3 | 2 | 1 | +------------+----+----+----+----+ and I would like to set all the

When I add xx to mysql float column, it is wrong result, Is it a bug?

十年热恋 提交于 2021-02-10 07:11:52
问题 My mysql: 5.6.16 my table info : CREATE TABLE `xxx` ( `uid` int(11) NOT NULL, `money` float(10,2) NOT NULL DEFAULT '0.00' , `real_money` float(10,2) NOT NULL , `available_invoice` float(10,2) DEFAULT NULL, PRIMARY KEY (`uid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; my table content is : 1 100000.00 0.00 0.01 30 99992560.00 0.03 0.00 61 65216.00 0.03 0.00 79 10.00 0.00 0.00 80 10.00 0.00 0.00 81 -70.00 0.00 0.00 83 60.00 0.00 0.00 100 100.00 50.00 50.00 889 980.00 0.00 0

MYSQL nested query running very slow?

淺唱寂寞╮ 提交于 2021-02-09 19:04:21
问题 The following query is constantly timing out, is there a less overhead way to achieve the same function ? UPDATE Invoices SET ispaid = 0 WHERE Invoice_number IN (SELECT invoice_number FROM payment_allocation WHERE transactionID=305) What I'm doing is unallocating invoices from a transaction, there can be up to 30+ records returned but it stops the database dead everytime I try to run it 回答1: USE JOIN instead of subquery it will improve the performance. Create index on Invoice_number column in

MYSQL nested query running very slow?

折月煮酒 提交于 2021-02-09 19:03:38
问题 The following query is constantly timing out, is there a less overhead way to achieve the same function ? UPDATE Invoices SET ispaid = 0 WHERE Invoice_number IN (SELECT invoice_number FROM payment_allocation WHERE transactionID=305) What I'm doing is unallocating invoices from a transaction, there can be up to 30+ records returned but it stops the database dead everytime I try to run it 回答1: USE JOIN instead of subquery it will improve the performance. Create index on Invoice_number column in

MYSQL nested query running very slow?

ぃ、小莉子 提交于 2021-02-09 18:58:09
问题 The following query is constantly timing out, is there a less overhead way to achieve the same function ? UPDATE Invoices SET ispaid = 0 WHERE Invoice_number IN (SELECT invoice_number FROM payment_allocation WHERE transactionID=305) What I'm doing is unallocating invoices from a transaction, there can be up to 30+ records returned but it stops the database dead everytime I try to run it 回答1: USE JOIN instead of subquery it will improve the performance. Create index on Invoice_number column in

MSSQL Deadlock when update withc (updlock)

谁说胖子不能爱 提交于 2021-02-08 06:25:18
问题 I got deadlock while updating. The transaction level is set to Read Committed . How to avoid deadlock in such situation? In other cases WITH (NOLOCK) and WITH (UPDLOCK) helped. I got the following T-SQL query: IF EXISTS (SELECT 1 FROM DEBTORS_CUSTOMERS WITH (NOLOCK) WHERE DebtorId = @DebtorId AND ClientFCCustomerNumber = @CustomerNumber) UPDATE DEBTORS_CUSTOMERS WITH (UPDLOCK) SET StatusId = @StatusId WHERE DebtorId = @DebtorId AND ClientFCCustomerNumber = @CustomerNumber ELSE INSERT INTO

Hibernate @DynamicUpdate(value=true) @SelectBeforeUpdate(value=true) performance

好久不见. 提交于 2021-02-07 11:32:10
问题 i am start using this 2 hibernate annotations in my APP. @DynamicUpdate(value=true) @SelectBeforeUpdate(value=true) first i will try to explain what i understand about it to know if i am right about it. @DynamicUpdate(value=true) updates only the modified values in the entity Hibernate needs to track those changes @SelectBeforeUpdate(value=true) creates a select before update to know which properties has been changed this is useful when the entity has been loaded and updated on different

UPDATE table_name SET col_name = varchar WHERE col_name is NULL;

雨燕双飞 提交于 2021-02-05 09:29:19
问题 The following UPDATE fails :- UPDATE table_name SET col_name = varchar WHERE col_name is NULL; The failure message is :- ERROR: column "varchar" does not exist Whereas the undermentioned one succeeds :- UPDATE table_name SET col_name = 889977 WHERE col_name is NULL; I have checked the pg_typeof of the column - col_name is character varying . Kindly help. 回答1: i think you missed quote for string UPDATE table_name SET col_name = 'varchar' WHERE col_name is NULL; 来源: https://stackoverflow.com

JAVA JDBC mySql Prepared statement Update query [duplicate]

柔情痞子 提交于 2021-02-05 07:45:27
问题 This question already has answers here : MySQLSyntaxErrorException near “?” when trying to execute PreparedStatement (2 answers) Closed 1 year ago . I am trying to execute the following code package jdbclesson; import java.sql.*; public class PreparedQuery { public static void main(String[] args) throws Exception { String url = "jdbc:mysql://localhost:3306/alien?useSSL=false"; String uname = "root"; String pass = "ma123"; String query = "UPDATE student SET username= ? where userid= ? ";