MySQL Forums
Forum List  »  Optimizer & Parser

Re: prepare don't work for optimize statement
Posted by: Øystein Grøvlen
Date: March 22, 2017 01:34AM

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

Options: ReplyQuote


Subject
Views
Written By
Posted
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.