You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-Renamed directory and script file name to match it's purpose.
-Generalization of the script.
-Insertion of README.md file.
-Version 0.2 of the script.
**IMPORTANT: I AM NOT RESPONSIBLE FOR ANY DATA OR DATABASE WHICH HAS BEEN INCORRECTLY REPAIRED OR CORRUPTED COMPLETELY!**
11
+
12
+
This is a simple procedure that I used to repair a large database with hundreds of tables. Doing it manually would be absolutely exhaustive and insane, so keeping that in mind, I've created a procedure that automates this process by taking the name of every table in the especific database that you want to restore and runs the restore command.
13
+
14
+
Although it's simple it uses the concept of Dynamic SQL so that it is possible to execute queries through the Prepared Statements, because it isn't possible to pass the name of tables through normal queries as parameters to a system function. The CHECK TABLE function is not yet supported by the Prepared Statements in **MySQL Server 8**.
15
+
16
+
*Any error or wrong information please contact.*
17
+
18
+
## Português
19
+
20
+
**IMPORTANTE: NÃO ME RESPONSABILIZO POR QUALQUER DADO OU BANCO DE DADOS QUE FORA REPARADO INCORRETAMENTE OU SE CORROMPEU POR COMPLETO!**
21
+
22
+
Essa é um procedimento simples que utilizei para reparar um banco de dados grande com centenas de tabelas. Fazê-lo manualmente seria absolutamente exaustivo e insano, então tendo isso em mente, criei um procedimento que automatiza esse processo pegando o nome de cada tabela no banco de dados especificado que você quer restaurar e executa o comando de restauração.
23
+
24
+
Apesar de ser simples ele utiliza o conceito de SQL Dinâmico para que seja possível executar as consultas através das *Prepared Statements*, pois não é possível passar o nome de tabelas através de consultas normais para uma função do sistema. A função de checar as tabelas (CHECK TABLE) ainda não é suportada pelas *Prepared Statements* no **MySQL Server 8**.
25
+
26
+
*Qualquer erro ou informação incorreta por favor contatar.*
27
+
28
+
## References
29
+
30
+
REPAIR TABLE:
31
+
32
+
*[Repair all tables in one go - Stack Overflow](https://stackoverflow.com/questions/4582832/repair-all-tables-in-one-go)
33
+
*[REPAIR TABLE Syntax- MySQL Documentation](https://dev.mysql.com/doc/refman/8.0/en/repair-table.html)
*[CREATE TEMPORARY TABLE Syntax- MySQL Documentation](https://dev.mysql.com/doc/refman/8.0/en/create-temporary-table.html)
39
+
*[How to create Temporary Table with SELECT INTO - Stack Overflow](https://stackoverflow.com/questions/11491240/how-to-create-temp-table-with-select-into-temptable-from-cte-query)
40
+
41
+
VARIABLES:
42
+
43
+
*[How to set variable from a SQL Query](https://stackoverflow.com/questions/3974683/how-to-set-variable-from-a-sql-query)
44
+
*[Local Variable DECLARE Syntax- MySQL Documentation](https://dev.mysql.com/doc/refman/8.0/en/declare-local-variable.html)
45
+
*[Use a variable for table name - Stack Overflow](https://stackoverflow.com/questions/2754423/use-a-variable-for-table-name-in-mysql-sproc)
46
+
47
+
WHILE LOOP:
48
+
49
+
*[WHILE LOOP Syntax- MySQL Documentation](https://dev.mysql.com/doc/refman/8.0/en/while.html)
50
+
*[INSERT with WHILE LOOP - Stack Overflow](https://stackoverflow.com/questions/26981901/mysql-insert-with-while-loop/26983030)
51
+
*[SELECT INTO - W3Schools](https://www.w3schools.com/sql/sql_select_into.asp)
52
+
*[Looping through all tables on a database - Stack Overflow](https://stackoverflow.com/questions/37313983/how-to-loop-through-all-the-tables-on-a-database-to-update-columns)
53
+
54
+
AUTO_INCREMENT:
55
+
56
+
*[How to generate Auto-increment field in SELECT query - Stack Overflow](https://stackoverflow.com/questions/16555454/how-to-generate-auto-increment-field-in-select-query)
57
+
58
+
PARAMETERS:
59
+
60
+
*[Passing table names as parameters - Stack Overflow](https://stackoverflow.com/questions/25124034/passing-a-table-name-as-a-parameter)
61
+
*[Passing table name as a parameter in stored procedure - SQL SERVER CENTRAL](https://www.sqlservercentral.com/Forums/485395/pass-table-name-as-a-parameter-in-stored-procedure)
62
+
63
+
PROCEDURE:
64
+
65
+
*[CREATE PROCEDURE Syntax- MySQL Documentation](https://dev.mysql.com/doc/refman/8.0/en/create-procedure.html)
66
+
67
+
PREPARED STATEMENTS:
68
+
69
+
*[Prepared SQL Statement Syntax - MySQL Documentation](https://dev.mysql.com/doc/refman/8.0/en/sql-syntax-prepared-statements.html)
70
+
*[PREPARE Syntax - MySQL Documentation](https://dev.mysql.com/doc/refman/8.0/en/prepare.html)
0 commit comments