1. 查詢(xún)Mysql的進(jìn)程
-- 查看全部進(jìn)程
show processlist;
-- 查詢(xún)進(jìn)行中的進(jìn)程
select *from information_schema.processlist where command not in('Sleep','Killed');
-- 查詢(xún)某個(gè)庫(kù)的進(jìn)程
select *from information_schema.processlist where db='dw';
-- 殺掉某進(jìn)程, 從上述進(jìn)程中獲取某任務(wù)的首字段即為進(jìn)程id
kill ***;
2. 導(dǎo)出存儲(chǔ)過(guò)程sql語(yǔ)句
select
concat(
char(10),'drop procedure if exists ',ROUTINE_NAME,';',char(10),
'create procedure ',ROUTINE_NAME,'()',char(10),
ROUTINE_DEFINITION,';',char(10)
)
from information_schema.ROUTINES
where routine_schema = 'dw' -- 目標(biāo)庫(kù)
and routine_name in('dw_test'); -- 目標(biāo)存儲(chǔ)過(guò)程名稱(chēng)
3. 導(dǎo)出含參數(shù)的存儲(chǔ)過(guò)程sql語(yǔ)句
select
concat(
char(10),'drop procedure if exists ',ROUTINE_NAME,';',char(10),
'create procedure ',ROUTINE_NAME,'(',
convert(( select param_list from mysql.proc n where n.db = 'dw' -- 目標(biāo)庫(kù)
and n.name = m.ROUTINE_NAME),char)
,')',char(10),
ROUTINE_DEFINITION,';',char(10)
)
from information_schema.ROUTINES m
where routine_schema = 'dw' -- 目標(biāo)庫(kù)
and routine_name in('dw_test'); -- 目標(biāo)存儲(chǔ)過(guò)程名稱(chēng)
4. 獲取表的建表語(yǔ)句(shell處理)
show create table 其實(shí)可以返回,然后借助shell語(yǔ)句截取處理一下
table_sqls=`mysql -h**** -u**** -p**** -P*** -D*** -e"show create table test_table"|awk -F'\t' '{print $2}'`
echo "drop table if exists $line;"$table_sqls";">>$target_sql
echo $target_sql
每天進(jìn)步一點(diǎn)點(diǎn)
浙公網(wǎng)安備 33010602011771號(hào)