0

I am creating database at runtime and I want to create the tables in that database at the same time. Can anyone give me any thought on how to do that? For Example -

I have created one database named 'mydb' and now in the same process I am trying to create the table I am using the mysql stored procedure for the same. My proc input will be my dbname. So, my proc looks like

create procedure test(IN dbname varchar(100))
begin 
    create table `dbname`.`testing`(testid int, testname varchar(45));
end

1 Answer 1

2

You can use the PREPARE feature to execute dynamic SQL.

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

Comments

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.