mysql数据库自动分区

发布于 2024-08-19 23:41:28 字数 162 浏览 8 评论 0原文

我有一个 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 技术交流群。

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

发布评论

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

评论(3

浅忆 2024-08-26 23:41:28

有一些解决方案,如果您想要完整的解决方案,请检查此 在 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.

枫以 2024-08-26 23:41:28

是的,您可能喜欢 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

晒暮凉 2024-08-26 23:41:28

我将做其他人所做的事情(发布链接)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

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