请教一个多条批量更新的SQL语句

请教一个多条批量更新的SQL语句,第1张

declare @output varchar(8000)

select @output=coalesce(@output,'')+ aname +'=case '+aname+' when 0 then 5 when 1 then 4 when 2 then 3 when 3 then 4 else 1 end,' from syscolumns a

left join sysobjects b

on aid=bid where bname='tb'

select @output=substring(@output,1,LEN(@output)-1)

exec(N'update tb set '+@output+'')

--如果只 *** 作部分列,就复制一个空白表

select top 0 a,b,g into tb1

declare @output varchar(8000)

select @output=coalesce(@output,'')+ aname +'=case '+aname+' when 0 then 5 when 1 then 4 when 2 then 3 when 3 then 4 else 1 end,' from syscolumns a

left join tempdbsysobjects b

on aid=bid where bname='tb1'

select @output=substring(@output,1,LEN(@output)-1)

exec(N'update tb set '+@output+'')

类似于这种做批量更新 Configuration c= thisgetSqlSession()getConfiguration(); ManagedTransactionFactory managedTransactionFactory = new ManagedTransactionFactory(); BatchExecutor batchExecutor=new BatchExecutor(c,managedTransactionFactorynewTransaction(thisgetSqlSession()getConnection(),false)); int i = 0; for (JavaBean entity : list) { batchExecutordoUpdate(cgetMappedStatement(sql), entity); if (i++ > 0 && i % BATCH_SIZE == 0) { batchExecutordoFlushStatements(); } } batchExecutordoFlushStatements();

有关linux:

1、卸载某一个特定的挂在点。

umount /dev/datavg01 /data01

2、移掉lvm。

vgremove /dev/datavg01

3、拷贝数据

scp -r /home/gaogetxt root@192168101:/opt 或rsync -av /root/rpmpkgs /tmp/backups/

4、显示系统盘符并以树状格式展开。

lsblk。

5、扫描新增设备。

echo "---" >/sys/class/scsi-host/hosto/scan

6、强行杀死mysql

kill -9 $(ps -ef | grep mysql)

7、将文件内容以每一行5个的形式展示出来。

cat test2txt | xargs -n 5

8、用cut去实现awk切割列的效果

cat/etc/passwd | cut -d : -f 2

9、sed、grsp、awk。之前已经说过了、具体看 从linux三剑客说起 这篇。

10、增加一个oracle用户让其属于oinstall组同时也隶属于dba组。useradd oracle -g oinstall -G dba

11、新建立一个组groupnew并将组id修改为255。

groupadd -g 255 groupnew

12、将本地/dev/hdb整盘中的数据备份到/dev/hdd上。

dd if=/dev/hdb of=/dev/hdd

13、查看服务器cpu个数。

cat /proc/cpuinfo | grep "physical id" | wc -l

14、查看服务器io状况并以每间隔1秒的速度输出5次。

iostat 1 5

15、查看服务器内存使用情况并以每间隔2秒的速度输出10次。

vmstat 2 10

16、将gaogetxt中的第一列db2找到并将db两个字符用ab替换。

cat gaogetxt |grep db2 | awk -F 2 '{print $1}' | tr db ab

17、将包名解压到指定目录。

tar -cxvf 包名 -C 指定的目录

18、linux中前后台任务切换。

ctrl+z 切换到后台、jobs显示id、fg + id 切换至前台。

19、杀掉top下stopped的进程。

ps -A -ostat,ppid,pid,cmd |grep -e '^[T]'

然后在进行kill

20、监控cpu状态。

mpstat

21、查看虚拟内存使用了多少。

swapon

22、每月1到10号4:45重启nginx。

crontab -u root -l 显示root当前的计划任务。

crontab -u root -e 后输入以下内容并保存退出。

45 4 1,10 systemctl start nginx

23、awk打印df -h 的第一列、第三列、最后一列。

df -h | awk '{print $1 " " $3 " " $NF}'

24、批量拉、打标签、推docker镜像的shell脚本。

#!/bin/bash

for image in 'docker images | grep 10171101:10000 | awk ' { print $1 ":" $2 }

do

version = 'echo $image | awk -F / ' { print $2 } '

docker tag $image 192168101/$version

docker push 192168101/$version

done

25、正则表达式匹配电话号码。

(0d{2}[) -]d{8}

26、编译安装三步骤。

/configure --prefix=安装目录

make

make install

有关kubernetes:

将kubernetes中pod的数据拷贝到物理宿主机上。

kubectl cp gyl-run/gyl-mysql-01020304: /opt/dockersh /opt

将kubernetes中物理宿主机上的数据拷贝到pod中。

kubectl cp /opt/dockersh gyl-run/gyl-mysql-01020304: /opt

检查当前用户有没有权限在k8s中创建资源权限。

kubectl auth can-i '' ''

检查当前用户有没有权限在k8s集群中创建namespace权限。

kubectl auth can-i create pods --all-namespaces

查看集群是否 健康 。

kubectl get cs

有关数据库:

查看 mysql 二进制日志格式。

show variables like ‘%binlog_format%’

查看所有二进制日志文件

show master logs

查看正在写入的二进制日志

show master status

格式化二进制显示为sql格式

mysqlbinlog --base64 --output=decode-rows -v --start-date="2019-01-25 00:00:00" --stop-date=“2019-01-26 17:30” master-bin000006

利用bin-log去还原数据

/usr/bin/mysqlbinlog --no-default /var/lib/mysql/mysql-bin00001 | usr/bin/mysql -u root -p pwd test

连接 postgresql

psql -U 用户名 -d 数据

数据库名 -h 主机地址 -p端口(默认端口为5432)

l 显示数据库列表

d 显示所有表

d 表名称 显示表结构

du 显示所有数据库用户

c 数据库名 连接数据库

q 退出pg窗口

pg备份:

pg_dump -U kong -d kong -f /opt/2019-01-26-pgsql

pg还原:

psql -d kong -U kong -f /opt/2019-01-26-pgsql

mongo 批量更新数据:把age大于20的class name修改为,设置multi为true

以上就是关于请教一个多条批量更新的SQL语句全部的内容,包括:请教一个多条批量更新的SQL语句、springboot中使用mybatis-plus,用到了它的批量保存和更新的方法,就是saveBatch和saveOrUpdateBatch、linux和k8s和数据库笔记等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/sjk/9430307.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-28
下一篇 2023-04-28

发表评论

登录后才能评论

评论列表(0条)

保存