我们可以在MySQL中动态创建表吗?
我们可以在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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
如果你有足够的权限,你只需要使用相同的 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.
是的,您可以在程序执行之前、期间或之后的任何时刻在 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
是的,这是可能的。
Yes, it is possible.
动态??就像执行插入、更新或删除语句一样...我不知道这是否是您的意思,但您可以查看 触发器
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
是的。这只是一个简单的MYSQL语句。假设您使用 PHP。
然后您在 PHP 中执行该语句。
当然,这假设您拥有特权。
Yes. It's just a simple MYSQL statement. Suppose you're using PHP.
and you execute that statement in PHP.
This assumes you have privileges, of course.
绝对是的,尽管我可能会质疑这样做是否明智,除非它是针对某种实际的数据库管理组件。
Absolutely yes, though I might question the wisdom of doing so unless it's for some sort of actual database-management component.