I want to create and use a database/schema by using a variable, so I can change it when I want to run a script on a different Schema.
I have something like this:
SET @VarSchema = 'test';
SET @Front = 'CREATE DATABASE IF NOT EXISTS ';
SET @EndPart = ';';
SET @Stmt = CONCAT(@Front,@VarSchema,@EndPart);
PREPARE stmt FROM @Stmt;
EXECUTE stmt;
SET @Front = 'USE ';
SET @EndPart = ';';
SET @Stmt = CONCAT(@Front,@VarSchema,@EndPart);
PREPARE COMMAND FROM @Stmt;
EXECUTE COMMAND;
But this gives me this error: Error Code: 1295. This command is not supported in the prepared statement protocol yet
EDIT: It complains about this statement:
SET @Front = 'USE ';
SET @EndPart = ';';
SET @Stmt = CONCAT(@Front,@VarSchema,@EndPart);
PREPARE COMMAND FROM @Stmt;
EXECUTE COMMAND;
Is there any way I can do this?