shell指令碼同時刪除多張表

2021-08-11 06:46:30 字數 551 閱讀 1358

#同時刪除表名類似的多張表

#引數1是資料庫名 引數2傳表名

#!/bin/sh

if [ $# -ne 2 ];then

echo "input argument dbname universaltablename"

exit 1;

fimysqlconnect='mysql'

droptable=`$mysqlconnect -e "select concat( 'drop table ', group_concat(table_name) , ';' ) 

as statement from information_schema.tables where table_schema = '$1' and table_name like '$2%';" | grep -v statement`         

#注意使用~鍵中的那個點,將刪除表的命令複製給droptable_sql變數

echo $droptable;    #列印要刪除所有表

$mysqlconnect -e"use $1;$"   #執行刪除命令

mysql delete語句刪除多張表

功能介紹 來從多個表中刪除資料。mysql允許delete語句中使用inner join子句來從表中刪除和另乙個表中的匹配的行記錄。從符合指定條件的t1和t2表中刪除行記錄 例項 從符合指定條件的t1和t2表中刪除行記錄 delete t1,t2 from t1 inner join t2 on t...

Dapper同時操作任意多張表的實現

using microsoft.extensions.configuration using system using system.collections.generic using system.text namespace feg.esb.data.ef catch exception 查詢 ...

使用字元函式刪除多張表

常見的得到多表有規則刪除語句是這樣的 select drop table table name from user tables where table name like t table 我這邊有個較奇怪的邏輯 取字尾為 his的表的除去 his外的表名後刪除 必須聯合字串函式 instr 取字串...