在 mySQL 中对表进行分区
有一个包含 300 万行的表,想要对其进行分区。有 5 列,其中一列是日期列。我想按日期拆分表格。任何简单的帮助都会很棒。谢谢
Have a table with 3 million rows and would like to partition it. There are 5 columns, one of them which is a date column. I would like to split up the table by dates. Any easy help would be great. Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果我正确理解您的问题,有几种方法可以做到这一点:
您可以使用 Between 关键字按特定日期范围进行细分。
或者,如果您的细分更简单(例如您想按年份细分),您可以使用日期函数。
可能还有更动态的方法来做到这一点,但我需要听到有关您的环境和目标的更多详细信息。
If I'm understanding your question correctly, there are a couple of ways to do this:
You could do it using the Between keyword to break down by specific date ranges.
Or if your breakdown is more simple (e.g. you want to break down by year), you can use the date functions.
There are probably more dynamic ways to do this as well, but I would need to hear some more details of your environment and goals.
你说的把桌子分开是什么意思?
您可以通过执行插入选择并选择现有数据在日期列上执行自 JOIN GROUP BY 来插入到其他表中。
What do you mean by split up the table?
You can insert into other tables by performing an insert-select and selecting your existing data doing a self JOIN GROUP BY on the date column.
您可以在 MySQL 中使用表分区。步骤如下:
备份您的表。
从数据库中删除表
运行创建表查询和分区语句。
示例:http://dev.mysql.com/tech-resources/文章/partitioning.html
现在导入表的数据。
You can use Table Partitioning in MySQL. Steps Are:
Take a backup of your table.
Drop Table from your Database
Run the create table query along with partition statement.
example : http://dev.mysql.com/tech-resources/articles/partitioning.html
Now Import data of your table.