开发者

How to create dynamic table in mySql

开发者 https://www.devze.com 2023-03-06 20:07 出处:网络
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 ?

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


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


Pretty easy to do:

 CREATE TABLE AS
 SELECT * FROM tblCustomer

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号