如何在mySql中创建动态表

发布于 2024-11-09 02:38:34 字数 414 浏览 4 评论 0原文

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

例如:在 Sql 服务器中,我创建了动态客户表。

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

  SELECT * FROM @tblCustomer

请帮忙

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

〗斷ホ乔殘χμё〖 2024-11-16 02:38:34
@sqlstmt = 'whatever sql';
Prepare st from @sqlstmt;
Execute @st;
Deallocate prepare @st;

将 CREATE TABLE 语句放入 @sqlstmt 中,就可以开始了!

这张桌子是真的。之后您将不得不放下桌子。

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

清醇 2024-11-16 02:38:34

非常容易做到:

 CREATE TABLE AS
 SELECT * FROM tblCustomer

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

Pretty easy to do:

 CREATE TABLE AS
 SELECT * FROM tblCustomer

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文