mysql数据库自动分区
我有一个 mysql 数据库表,我想按日期分区,特别是按月和分区。年。但是,当添加新月份的新数据时,我不希望需要手动更新数据库。
当我最初创建数据库时,我有 11 月 9 日、12 月 9 日、1 月 10 日等的数据。现在,当 2 月开始时,我希望自动创建 2 月 10 日的分区。这可能吗?
I have a mysql database table that I want to partition by date, particularly by month & year. However, when new data is added for a new month, I don't want to need to manually update the database.
When I initially create my database, I have data in Nov 09, Dec 09, Jan 10, etc. Now when February starts, I'd like a Feb 10 partition automatically created. Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有一些解决方案,如果您想要完整的解决方案,请检查此 在 kickingtyres 上发布。它是处理分区分析和创建的存储过程的基本组合(带有一些日志记录!)。
您需要做的就是将其调整为您的分区类型(示例使用 bigint 分区)并安排该过程与 MySQL 事件调度程序一起运行。
There are a few solutions out there, if you want a total solution, check this post out on kickingtyres. It's a basic combination of a stored procedure handling the partition analysis and creation (with some logging!).
All you need to do is adjust it to your partition type (the example uses a bigint partition) and schedule the procedure to run with the MySQL Event Scheduler.
是的,您可能喜欢 5.5 中增强的分区功能:
http://dev. mysql.com/tech-resources/articles/mysql_55_partitioning.html
yes, you might like the enhanced partitioning functionality in 5.5:
http://dev.mysql.com/tech-resources/articles/mysql_55_partitioning.html
我将做其他人所做的事情(发布链接)MySQL 分区快速介绍
(请参阅第 50 页了解您需要的内容 - 按日期分区)
编辑:我更仔细地重读了您的帖子 - 如果您想按月更改分区,为什么不创建一个 Mysql
event
来执行此操作I will do what the other done (post a link) Quick Introdunction to MySQL Partitioning
(look at page 50 for what you need - partition by date)
Edit: I reread your post more carefully - if you want to change partitions by month why don't you create a Mysql
event
that does that