0

I want to execute the queries based on Database version, this is my requirement If the MySQL database version is 5.6 i want to alter the table column and add full text otherwise if version is less i don't want to alter the table. The reason behind is i want to do LIKE %Something% against the column and the table is created using INNODB schema, as am not an expert in MySQL DB i googled for LIKE query performance for 2M+ records. Most of them are against using LIKE with double %. And also this InnoDB Fulltext support. So if i make the query to be executed based on DB version most of the users will get the benefit but who ever in the older version of DB(not willing to update) should adjust with performance. Thanks in advance.

1 Answer 1

2

You can do this using a stored procedure like this:

DELIMITER $$

CREATE

    PROCEDURE `test`.`temp`()

    BEGIN
declare version1 varchar(10);

set version1 = (select version());

if(version1 like '5.6%') then
----  your alter query here 
end if;

    END$$

DELIMITER ;
Sign up to request clarification or add additional context in comments.

4 Comments

this looks like a nice solution. Do people do that?
Achha! This is pretty useful then. Cool!
I mean use it.. Thanks :)
Thanks @AmanAggarwal it helped to solve the issue. I want to add more info on alter statement inside MySQL ` SET @ddl = CONCAT('ALTER TABLE ', MYTABLE, 'ADD FULLTEXT INDEX some_index column (', COLNAME ')'); PREPARE STMT FROM @ddl; EXECUTE STMT;}`

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.