1
Good night, everybody, all right?
I’m having a little silly doubt about the return of commands ANALYZE TABLE
and SHOW
in Mysql.
I know that if I make a query using SELECT
I can store the desired values in variables in two ways (as far as I know), which would be this:
SET @Name= SELECT Name FROM users WHERE Id = 1;
Or that:
SELECT Name INTO @Name FROM users WHERE Id = 1;
I particularly prefer the second way, because I could fill more than one variable with a single query, but my question is not about the SELECT
and its ways of storing query results in variables, rather how to store the values that a ANALYZE TABLE
or that a SHOW
return.
If I run, for example, the command ANALYZE TABLE users
in a schema
called test, I will have this result:
And I’d like to store the Msg_text
in a variable for example, maybe to use in some algorithm that sends an alert email, or something similar.
I believe that if there is a way to store the result of a ANALYZE TABLE
variable, would be in a similar way to store the result of a SHOW CREATE PROCEDURE
, or some other SHOW
, although I realized that most of the information that this command returns is stored in the base information_schema
, but I ended up getting curious if it would have how to store the return of this command as well.
What you need is certainly possible, but I would recommend taking a look at the documentation of the functions to see if it really is acting according to your expectations. The
ANALYZE TABLE
, for example, clean statistical data from the table under analysis, according to the documentation (last paragraph).– Diego Rafael Souza