Search code examples
mysqldynamic-tables

How to create dynamic table in mySql


I want to know how to create dynamic table in mySql . I have used dynamic table in Sqlserver 2008 but i am new to mySql . Is it possible ?

Eg: In Sql server i have created Dynamic Customer Table.

DECLARE @tblCustomer as table(
            [ ] bit
            ,Sl#        int
            ,custID     int
            ,CustCode   varchar(max)
            ,Customer   nvarchar(max)
            ,Authorized bit
            ,RCount     int)

  SELECT * FROM @tblCustomer

Please Help


Solution

  • @sqlstmt = 'whatever sql';
    Prepare st from @sqlstmt;
    Execute @st;
    Deallocate prepare @st;
    

    Place the CREATE TABLE statement in @sqlstmt and you are good to go !

    The table is a real one. You would have to drop the table afterwards.