1

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

2 Answers 2

2
@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.

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

Comments

1

Pretty easy to do:

 CREATE TABLE AS
 SELECT * FROM tblCustomer

It will take the existing field types from the schema where possible..

2 Comments

how can we create a new table with diffrent name from the tblCustomer?
Just give it the name, like this: CREATE TABLE companies_test AS SELECT * FROM companies @BijuKalanjoor

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.