add: rename database name shell script
This commit is contained in:
1 parent
f1ec33820c
commit
5c987ec1d9
1 file changed
+12
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
dbuser=root
|
||||||
|
dbpasswd=1000omc@kp!
|
||||||
|
|
||||||
|
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'")
|
||||||
|
|
||||||
|
for table in $list_table
|
||||||
|
do
|
||||||
|
mysql -u$dbuser -p$dbpasswd -e "rename table $1.$table to $2.$table"
|
||||||
|
done
|
||||||
Reference in new issue
Block a user