Re: prepare don't work for optimize statement
Hi,
Ref.
https://dev.mysql.com/doc/refman/5.7/en/prepare.html:
"Parameter markers can be used only where data values should appear, not for SQL keywords, identifiers, and so forth."
To dynamically build SQL, you can build the statement in a string, and then prepare the resulting string. For example:
SET @tab = 't1';
SET @str = CONCAT('OPTIMIZE TABLE ', @tab);
PREPARE stmt FROM @str;
Øystein Grøvlen,
Senior Principal Software Engineer,
MySQL Group, Oracle,
Trondheim, Norway
Subject
Views
Written By
Posted
1077
March 22, 2017 12:30AM
Re: prepare don't work for optimize statement
580
March 22, 2017 01:34AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.