tags:

views:

136

answers:

7

Can we create tables dynamically in MySQL? If so, how? Dynamic means at run time....ie via procedure AND HOW???? I am using dotnet Ans--> yes we can create...but problem is i want to change the name of table each time the procedure is called....

A: 

Yes, look at this

Ikke
A: 

Yes, it is possible.

Joachim Sauer
+4  A: 

If you have sufficient privileges, you only need to use the same SQL statement(s) you would use in the administrative interface to create tables.

tvanfosson
+3  A: 

Yes, you can build tables in MySQL at any point before, during, or after program execution.

Depending on your needs, you may want to create tables during execution as Temporary tables so that they get automatically cleaned up at the end of the session. Note that these tables will not be visible to other sessions as each session has it's own private version of the temp table and will not be available for you to view at the end of the session. Once created, you can index and access them within your program just like any other table. If you need data to be persistent and available across sessions, you should stick with plain old tables.

MySQL Create Table Syntax

RC
A: 

Dynamically?? like if an insert, update, or delete statement is performed...I don't know if this is what you meant but you can look into triggers

halocursed
A: 

Yes. It's just a simple MYSQL statement. Suppose you're using PHP.

q = "CREATE TABLE..";

and you execute that statement in PHP.

This assumes you have privileges, of course.

TIMEX
A: 

Absolutely yes, though I might question the wisdom of doing so unless it's for some sort of actual database-management component.

Greg D