“分区”有什么用? MySQL 中的关键字?
因为我是 MySQL 新手。这个 MySQL 语句中的 PARTITION
是什么意思?
CREATE TABLE employees (
id INT NOT NULL,
fname VARCHAR(30),
lname VARCHAR(30),
hired DATE NOT NULL DEFAULT '1970-01-01',
separated DATE NOT NULL DEFAULT '9999-12-31',
job_code INT NOT NULL,
store_id INT NOT NULL
)
PARTITION BY RANGE (store_id) (
PARTITION p0 VALUES LESS THAN (6),
PARTITION p1 VALUES LESS THAN (11),
PARTITION p2 VALUES LESS THAN (16),
PARTITION p3 VALUES LESS THAN (21)
);
As I am a MySQL newbie. What does PARTITION
mean in this MySQL statement?
CREATE TABLE employees (
id INT NOT NULL,
fname VARCHAR(30),
lname VARCHAR(30),
hired DATE NOT NULL DEFAULT '1970-01-01',
separated DATE NOT NULL DEFAULT '9999-12-31',
job_code INT NOT NULL,
store_id INT NOT NULL
)
PARTITION BY RANGE (store_id) (
PARTITION p0 VALUES LESS THAN (6),
PARTITION p1 VALUES LESS THAN (11),
PARTITION p2 VALUES LESS THAN (16),
PARTITION p3 VALUES LESS THAN (21)
);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
来自: MySQL 5.1 新功能:MySQL 分区
您还可以有兴趣寻求有关“水平分区”的更多信息,以便更好地了解此功能特别有用的场景。
From: MySQL 5.1 New Features: MySQL Partitions
You may also be interested in seeking further information on "horizontal partitioning", in order to better understand the scenarios where this is particularly useful.
分区通过拆分到不同的存储桶来帮助组织存储在表中的数据。
这类似于图书馆为不同主题设置单独的书架部分,而目录/索引卡抽屉通常按字母顺序分开。
这有两个好处:
您可以通过以下几个链接获取更多详细信息:
维基百科文章: http://en.wikipedia .org/wiki/Partition_(database)
有关分区的 MySQL 文档: http://dev.mysql.com/doc/refman/5.5/en/partitioning.html
Partitioning helps in organize the data stored in the table by splitting across different buckets.
This is analogous to how a library has separate sections of shelves for different subjects, while the catalogue/index card drawers are usually separated alphabetically.
This helps in two ways:
Here are a few links where you can get many more details:
Wikipedia article: http://en.wikipedia.org/wiki/Partition_(database)
MySQL documentation regarding partitions: http://dev.mysql.com/doc/refman/5.5/en/partitioning.html