This commit is contained in:
simonzhangsz committed 2023-11-08 16:51:44 +08:00
1 parent 5c987ec1d9
commit 24ccdf10d9
2 files changed
+8 -6

No files matched your search

+8 -3
View File
@@ -2,11 +2,16 @@
dbuser=root
dbpasswd=1000omc@kp!
dbhost=127.0.0.1
mysql -u$dbuser -p$dbpasswd -e 'create database if not exists $2;'
list_table=$(mysql -u$dbuser -p$dbpasswd -Nse "select table_name from information_schema.TABLES where TABLE_SCHEMA='$1'")
if [ $3 =~ ""]; then
dbhost=$3
fi
mysql -u$dbuser -p$dbpasswd -h $dbhost -e "create database if not exists $2;"
list_table=$(mysql -u$dbuser -p$dbpasswd -h $dbhost -Nse "select table_name from information_schema.TABLES where TABLE_SCHEMA='$1'")
for table in $list_table
do
mysql -u$dbuser -p$dbpasswd -e "rename table $1.$table to $2.$table"
mysql -u$dbuser -p$dbpasswd -h $dbhost -e "rename table $1.$table to $2.$table"
done