首页 > 数据库 >mysql利用批量生成打印语句

mysql利用批量生成打印语句

时间:2022-12-16 14:45:03浏览次数:32  
标签:语句 runwhole name 批量 ori mysql table id es

CREATE DEFINER=`root`@`%` PROCEDURE `print_create_runwhole_es_sql`()
begin
DECLARE p_name varchar(50);
DECLARE p_name_mix text;
DECLARE p_yw_key varchar(50);
DECLARE p_ori_table_id varchar(50);
DECLARE p_ori_table_name varchar(50);

declare stopflag int DEFAULT 0;
declare cursor_runwhole_es cursor for

select temp.es_table_name, dti.column_name , temp.ori_bus_key ,temp.ori_table_id,temp.ori_table_name
from ES_TEST_TEMP temp join
(
select M.ori_table_id , GROUP_CONCAT( concat('a.',M.column_name) order by M.seq asc ) column_name from (
select cast( id as SIGNED ) seq,tb_id ori_table_id, column_name
FROM data_item_info
order by cast( id as SIGNED ) ASC
)M group by M.ori_table_id
)dti on dti.ori_table_id =temp.ori_table_id
order by temp.ori_table_id asc

;


DECLARE CONTINUE HANDLER FOR NOT FOUND SET stopflag = 1 ;
open cursor_runwhole_es;
##目标表
drop table print_create_runwhole_es_sql;

create table print_create_runwhole_es_sql
(
es_table_name varchar(100),
create_runwhole_es TEXT
);


out_loop: LOOP
FETCH NEXT FROM cursor_runwhole_es INTO p_name , p_name_mix ,p_yw_key ,p_ori_table_id ,p_ori_table_name;

IF stopflag = 1 THEN
LEAVE out_loop;
END IF;

##循环体

insert into print_create_runwhole_es_sql
select p_name , concat ('spark {
spark.streaming.batchDuration = 5
spark.app.name = \"application_hiveToEs_', p_ori_table_id,'\"
spark.executor.instances =\"5\"
spark.executor.cores=\"8\"
spark.executor.memory=\"20g\"
spark.driver.memory=\"6g\"
spark.driver.cores=\"8\"
}
input {
hive {
pre_sql = \"select ',p_name_mix ,' from (select * ,row_number()over(partition by ',p_yw_key,' order by rksfm desc ) riadd from original.',p_ori_table_name,' ) a where a.riadd =1 \"
result_table_name = \"hive_test_1110\"
}
}
filter{}
output {
com.zdxf.bdwh1.datareverse.output.es.EsOutputRdd1{
es.nodes = \"53.80.10.101,53.80.10.102,53.80.10.103\"
es.port = \"39200\"
es.index.name = \"',p_name,'\"
es.batch.size.entries = 100000
}
stdout {}
}' );

set stopflag=0;
end loop out_loop ;
select * from print_create_runwhole_es_sql;
close cursor_runwhole_es;
end

标签:语句,runwhole,name,批量,ori,mysql,table,id,es
From: https://www.cnblogs.com/CloudHaiYun/p/16987317.html

相关文章

  • mysql复制备份清空表的技巧
    1.复制表结构及其数据:createtabletable_name_newasselect*fromtable_name_old2.只复制表结构:createtabletable_name_newasselect*fromtable_name_oldwh......
  • 别使用 MySQL 的 SQL_CALC_FOUND_ROWS 来获取总行数
    当我们在处理分页程序的时候,会使用limit来限制返回的数量,然后会有两种获取分页的方法:第一种方法:在SELECT语句中加入SQL_CALC_FOUND_ROWS选项,然后通过SELECTFOUND......
  • Ubuntu安装、配置Mysql8.0
    安装在线安装,依次执行如下命令sudoapt-getinstallmysql-serversudoaptinstallmysql-clientsudoaptinstalllibmysqlclient-dev安装完成后,输入sudonetstat......
  • 解决使用innobackupex备份mysql产生returned OS error 124【转】
    ###简介今天在使用innobackupex全量备份数据库的时候发生了下面的错误错误详情19070515:22:18>>logscannedupto(258819807308)xtrabackup:Generatingalist......
  • MySQL之删除
    方式一、语法:1.单表删除deletefrom表名where筛选条件#案例:删除手机号9结尾的女生信息deletefrombeautywherephonelike'%9';select*frombeauty方式二......
  • MySQL学习笔记2
    MySQL学习笔记2     导入sql文件mysql导入sql文件(命令行方式)1. 打开数据库命令行窗口;输入密码登录数据库;2. 查看所有数据库showdatabases;,并选择要......
  • C# 的DateTime 和 Mysql 的10位时间戳 转化
    1.将Unix时间戳转换为DateTime类型时间 publicstaticSystem.DateTimeConvertIntDateTime(longd){System.DateTimetime=System.DateTime.MinValue;System.Date......
  • Windows下安装mysql-python(MySQLdb)问题记录
    今天太倒霉了,这篇文章马上就要写完了,结果火狐崩溃了,而且csdn居然没有自动保存,只有上午的有记录;想到这个安装的问题也折腾哥快一天了,还是再次打字把问题记录下吧,我就喜欢偏......
  • MySQL之修改
    一、修改记录update表名set列=新值,列=新值,...where筛选条件#1.修改单表的记录#案例一、修改beauty表中姓唐的电话号码为138998899updatebeautysetpho......
  • Kylin-最小化编译安装MySQL
    Kylin-最小化编译安装MySQL编译环境部署安装编译软件[root@server2local]#dnfinstallgccgcc-c++ncursesncurses-develcmakebisonperlmaketar-yInstalle......