我们可以在MySQL中动态创建表吗?

发布于 2024-08-06 22:22:07 字数 161 浏览 3 评论 0原文

我们可以在MySQL中动态创建表吗?如果是这样,怎么办? 动态意味着运行时......即通过过程如何??? 我正在使用点网 答-->是的,我们可以创建......但问题是我想在每次调用过程时更改表的名称......

Can we create tables dynamically in MySQL? If so, how?
Dynamic means at run time....ie via procedure AND HOW????
I am using dotnet
Ans--> yes we can create...but problem is i want to change the name of table each time the procedure is called....

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

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

发布评论

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

评论(6

明天过后 2024-08-13 22:22:07

如果你有足够的权限,你只需要使用相同的 SQL 语句在管理界面中使用来创建表。

If you have sufficient privileges, you only need to use the same SQL statement(s) you would use in the administrative interface to create tables.

苏辞 2024-08-13 22:22:07

是的,您可以在程序执行之前、期间或之后的任何时刻在 MySQL 中构建表。

根据您的需要,您可能希望在执行期间创建表作为临时表,以便它们在会话结束时自动清理。请注意,这些表对其他会话不可见,因为每个会话都有其自己的私有版本的临时表,并且在会话结束时您将无法查看。创建后,您可以像任何其他表一样在程序中索引和访问它们。如果您需要数据在会话中持久且可用,那么您应该坚持使用普通的旧表。

MySQL 创建表语法

Yes, you can build tables in MySQL at any point before, during, or after program execution.

Depending on your needs, you may want to create tables during execution as Temporary tables so that they get automatically cleaned up at the end of the session. Note that these tables will not be visible to other sessions as each session has it's own private version of the temp table and will not be available for you to view at the end of the session. Once created, you can index and access them within your program just like any other table. If you need data to be persistent and available across sessions, you should stick with plain old tables.

MySQL Create Table Syntax

无风消散 2024-08-13 22:22:07

是的,这是可能的。

Yes, it is possible.

静若繁花 2024-08-13 22:22:07

动态??就像执行插入、更新或删除语句一样...我不知道这是否是您的意思,但您可以查看 触发器

Dynamically?? like if an insert, update, or delete statement is performed...I don't know if this is what you meant but you can look into triggers

紫南 2024-08-13 22:22:07

是的。这只是一个简单的MYSQL语句。假设您使用 PHP。

q = "CREATE TABLE..";

然后您在 PHP 中执行该语句。

当然,这假设您拥有特权。

Yes. It's just a simple MYSQL statement. Suppose you're using PHP.

q = "CREATE TABLE..";

and you execute that statement in PHP.

This assumes you have privileges, of course.

你げ笑在眉眼 2024-08-13 22:22:07

绝对是的,尽管我可能会质疑这样做是否明智,除非它是针对某种实际的数据库管理组件。

Absolutely yes, though I might question the wisdom of doing so unless it's for some sort of actual database-management component.

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