#!/bin/bash
# 设置数据库连接信息
host="127.0.0.1"
port="1234"
user="root"
password="xxxx"
database="xxxx"
# 获取所有表名
tables=$(mysql -h $host -P $port -u $user -p$password $database -e "SHOW TABLES;" | awk 'NR>1')
# 定义导出表的函数
export_table() {
table=$1
if [ -f ${table}.sql ]; then
echo "Table $table has already been exported, skipping..."
else
mysqldump -h $host -P $port -u $user -p$password --no-tablespaces --databases $database --tables $table > ${table}.sql || echo "Error exporting table $table, skipping..."
fi
}
# 遍历所有表,判断是否已经导出,如果没有则进行导出
for table in $tables; do
export_table $table
done
SHELL读取Doris指定库所有表并且分文件导出
最新推荐文章于 2024-12-02 18:19:29 发布