SQL语句,使用case when 实现批量更新数据 update table_name set status = case id when 1 then '正常' when 2 then '禁用' when 3 then '过期' end, rank = case id when 1 then 1 ...
                            
                            
                                分类:
数据库   时间:
2020-05-27 18:21:12   
                                阅读次数:
120
                             
                         
                    
                        
                            
                            
                                    有时候oracle的最后一个sql少个分号,要在end前面加上分号 oracle和mysql数据库的批量update在mybatis中配置不太一样: oracle数据库: <update id="batchUpdate" parameterType="java.util.List"> <foreac ...
                            
                            
                                分类:
数据库   时间:
2020-05-27 15:29:53   
                                阅读次数:
108
                             
                         
                    
                        
                            
                            
                                    https://blog.csdn.net/qq_36132599/article/details/89148708 https://blog.csdn.net/dmcpxy/article/details/81163735 ...
                            
                            
                                分类:
数据库   时间:
2020-05-27 15:18:19   
                                阅读次数:
199
                             
                         
                    
                        
                            
                            
                                语法:updat table_name set column_name1 = case id when 1 then 'a' when 2 then 'b' when 3 then 'c' end, colunm_name = case id when 1 then 'd' when 2 then  ...
                            
                            
                                分类:
数据库   时间:
2020-05-20 17:17:00   
                                阅读次数:
64
                             
                         
                    
                        
                            
                            
                                    需求:更新用户表的工号,格式为“GD1,GD2,...”的格式,如果有数据取最大值再递增 E1:先查询出是否有数据,有数据取最大值再递增,使用nvl函数 E2:创建Oracle序列,start with改为max值 E3:批量更新 E4:如果下次使用序列,记得更改start with的值,因为每次使 ...
                            
                            
                                分类:
数据库   时间:
2020-05-18 14:36:45   
                                阅读次数:
78
                             
                         
                    
                        
                            
                            
                                    如果把model先定义好变量,查询时用此变量,批量更新时就不能再用此变量了,会报重复ID错误。 解决办法是重新定义model变量,或直接this.model('xxx')。 以下为场景复原 const sql = `...` const model = this.model('xxx') const ...
                            
                            
                                分类:
Web程序   时间:
2020-05-15 11:21:33   
                                阅读次数:
79
                             
                         
                    
                        
                            
                            
                                    private function parseUpdate($data, $field,$table) { $sql = " update {$table} set "; //$keys = array_keys(current($data));print_r($keys);die; /* forea ...
                            
                            
                                分类:
数据库   时间:
2020-05-12 09:56:42   
                                阅读次数:
80
                             
                         
                    
                        
                            
                            
                                mysql 中update 可以和select配合使用,即更新的数据是用select查出来的; 举例: update b inner join(select x,y from m) n on b.x = n.x set b.y = n.y; 在修改或兼容以前的数据时,如果不用测试用例,就可以用此方式 ...
                            
                            
                                分类:
数据库   时间:
2020-05-07 13:34:34   
                                阅读次数:
72
                             
                         
                    
                        
                            
                            
                                    update email_content set Content = replace(Content ,'001.11','002.22')	Error Code: 1175. You are using safe update mode and you tried to update a tabl ...
                            
                            
                                分类:
数据库   时间:
2020-04-24 14:28:48   
                                阅读次数:
85
                             
                         
                    
                        
                            
                            
                                    最近有一个场景,在生产环境的一个库中,新增了一个字段。需要从另一个关联表中找到相当的字段回填。 影响数据数百万条。 首先,不能使用一条大的update语句来更新,这个锁太大,容易产生锁征用,造成死锁。 update B a set new_column=(SELECT other_col from  ...
                            
                            
                                分类:
数据库   时间:
2020-04-23 19:04:39   
                                阅读次数:
93