如何在mySql中创建动态表

时间:2022-08-27 01:11:44

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 ?

我想知道如何在mySql中创建动态表。我在Sqlserver 2008中使用了动态表,但我是mySql的新手。可能吗 ?

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

例如:在Sql server中我创建了动态客户表。

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 个解决方案

#1


2  

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

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

将CREATE TABLE语句放在@sqlstmt中,你很高兴!

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

桌子是真实的。之后你必须放弃桌子。

#2


1  

Pretty easy to do:

很容易做到:

 CREATE TABLE AS
 SELECT * FROM tblCustomer

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

它将尽可能从架构中获取现有的字段类型。

#1


2  

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

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

将CREATE TABLE语句放在@sqlstmt中,你很高兴!

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

桌子是真实的。之后你必须放弃桌子。

#2


1  

Pretty easy to do:

很容易做到:

 CREATE TABLE AS
 SELECT * FROM tblCustomer

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

它将尽可能从架构中获取现有的字段类型。