Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any way to change a non-partitioned table using nonclustered index to a partitioned table, if this table is partitioned by non-primary key? #57302

Closed
Nickelth opened this issue Nov 11, 2024 · 2 comments
Labels
type/feature-request Categorizes issue or PR as related to a new feature.

Comments

@Nickelth
Copy link

Feature Request

I tried to change a non-partitioned table using nonclustered index to a partitioned table, like:

create table t0(c0 int primary key nonclustered, c1 int);
alter table t0 partition by hash(c1) partitions 2;

But it reports:

ERROR 8264 (HY000): Global Index is needed for index 'PRIMARY', since the unique index is not including all partitioning columns, and GLOBAL is not given as IndexOption

The error message said I need to create global index first, but global index can only be created on partitioned table.

@Nickelth Nickelth added the type/feature-request Categorizes issue or PR as related to a new feature. label Nov 11, 2024
@Defined2014
Copy link
Contributor

Defined2014 commented Nov 12, 2024

Could use SQL below to do this.

alter table t0 partition by hash(c1) partitions 2 update indexes (`primary` global);

A ref doc link for it. pingcap/docs#18543

@Nickelth
Copy link
Author

Could use SQL below to do this.

alter table t0 partition by hash(c1) partitions 2 update indexes (`primary` global);

A ref doc link for it. pingcap/docs#18543

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature-request Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

No branches or pull requests

2 participants