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

Alter table supports adding or removing columns from primary key #5110

Open
killme2008 opened this issue Dec 6, 2024 · 1 comment
Open
Labels
C-enhancement Category Enhancements

Comments

@killme2008
Copy link
Contributor

What type of enhancement is this?

API improvement, User experience

What does the enhancement do?

Alter table statement must support adding or removing columns from primary key, maybe like:

ALTER TABLE table_name   
MODIFY PRIMARY KEY REMOVE (column1, column2, ...);  

ALTER TABLE table_name   
MODIFY PRIMARY KEY add (column1, column2, ...);  

Implementation challenges

No response

@killme2008 killme2008 added C-enhancement Category Enhancements good first issue Good for newcomers help wanted Extra attention is needed labels Dec 6, 2024
@evenyag evenyag removed good first issue Good for newcomers help wanted Extra attention is needed labels Dec 11, 2024
@evenyag
Copy link
Contributor

evenyag commented Dec 11, 2024

It's not easy to remove an existing column from or add an existing column to the primary key because the order of rows will change.

We also assume all rows are sorted in the same order in the storage engine. Maybe we can do this by copying an existing table and then rename them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category Enhancements
Projects
None yet
Development

No branches or pull requests

2 participants