Last active
December 21, 2023 12:28
-
-
Save rafesposo/0696d31e9dd9cd5d941e6f4c9c3c0d73 to your computer and use it in GitHub Desktop.
Use split.sh for split .sql file by table AND import.sh for import separated files and get file with error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for file in part_*.sql; do | |
mysql -u root -p'yourpass' DBNAME < "$file" | |
if [ $? -ne 0 ]; then | |
echo "Erro ao importar o arquivo: $file" | |
break | |
fi | |
done | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
awk '/CREATE TABLE/ {if (n) close("part_" n ".sql"); n++; } {print > ("part_" n ".sql")}' yourfile.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment