cockroachdb / cockroach

CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.
https://www.cockroachlabs.com
Other
29.89k stars 3.78k forks source link

Offer a interface to reset column ordinal position by modifying metadata #66122

Open bnuzhouwei opened 3 years ago

bnuzhouwei commented 3 years ago

We do have the internal metadata concepts to make this happen in a relatively inexpensive way. That being said, we have not implemented this functionality. Please file a github issue to track it and discuss various design point. I will warn you that I don’t think this is something we’re in any hurry to implement. That issue can also be a way to gauge interest and work out syntax details. (by ajwerner, Andrew Werner, Roacher)

The process of designing software is gradual. In the DB design process, we can’t do a perfect solution that considerded all the properties for implement the business. Some columns may be added, if new columns can only at the end of columns list. The automancally generated db document will be inaesthetic and unnatural, that will cost must time to reposion them in Words or Excel.

Describe the solution you'd like

MSSQL also provide a GUI tool for reposition the columns by automancally recreate the table. I think for CRDB is a NewSQL product with kv store, it is much easier to reposition columns without recreated table needed. May be just modify some metadata by (just like TiDB another NewSQL db):

alter table alter column columname after columnother

Describe alternatives you've considered

Or just updating the metabase:

update meta set attnum=@attnum where relname=@relname and attname=@attname

Jira issue: CRDB-7891

blathers-crl[bot] commented 3 years ago

Hello, I am Blathers. I am here to help you get the issue triaged.

It looks like you have not filled out the issue in the format of any of our templates. To best assist you, we advise you to use one of these templates.

I have CC'd a few people who may be able to assist you:

If we have not gotten back to your issue within a few business days, you can try the following:

:owl: Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

bnuboy commented 3 years ago

It is common to update the structure of the tables, thus it is very helpful for developers to modify the column ordinal position.

manavchawla98 commented 3 years ago

Hi! I'd like to help in solving this issue. Could you please give me some guidance on what part of the code to look at with some example use cases?

alimoosavi commented 2 years ago

@bnuzhouwei I am new to cockroachdb project and this issue seems attractive to me , please assign this issue to me.