S
Supabaseโ€ข3y ago
user8923

Change table column order

Is there a way to change the order or columns in the web-based table editor?
11 Replies
garyaustin
garyaustinโ€ข3y ago
No. The are ordered by the way they are defined in the table. Postgres has no special handling for ordering except the way they are defined. There are articles on google for ways to reorder columns with SQL, but they all basically are just methods that recreate the table or add to end and delete the previous column until you get your order the way you want it..
jdgamble555
jdgamble555โ€ข3y ago
There is a difference, however, between Supabase not having the ability to change the order it is displayed and Postgres not having the ability to change the stored order.
CanRau
CanRauโ€ข3y ago
uh nice, thanks for the localStorage hint, just deleted all localStorage and now it's working, before that it was showing in a different order and I think it even changed "randomly" between resetting migrations
user8923
user8923OPโ€ข3y ago
What's the hint about localStorage?
garyaustin
garyaustinโ€ข3y ago
I assume it is in reference to localStorage is used to save the order of columns in the table UI screen ONLY on a per computer/browser? basis. It does not change the API order. Or maybe jdgamble555 has mentioned something else somewhere and there is way that can be done at the API level, but I'm not familiar with it if so. I assume your question was can you change the order of the way queries return the data versus you just want to move columns in the UI table view for use there.
CanRau
CanRauโ€ข3y ago
yea sorry the "localStorage" hint just helped me solve my ui table related confusion in supabase dashboard ๐Ÿ˜…
jdgamble555
jdgamble555โ€ข3y ago
Nobody mentioned localstorage ๐Ÿคท๐Ÿผโ€โ™‚๏ธ
CanRau
CanRauโ€ข3y ago
then I must've hallucinated, might even be from the search results, anyway it helped in my case, sorry for interrupting ๐Ÿ˜‡
user8923
user8923OPโ€ข3y ago
Yeah I was looking for a quickie way to change the order of columns within the DB. I thought that maybe the Supabase team worked something into the UI so I don't have to do it manually in SQL like the old days. I've noticed that I could drag and drop columns in the UI but that's just visual.
jdgamble555
jdgamble555โ€ข3y ago
Nope. There doesn't seem to be a feature request for this either. Perhaps you should create one - https://github.com/supabase/supabase/issues. I think there is a difference between Postgres's arrangement, and Supabase's UI arrangement, so Supabase could do this easily. The position would have to be stored in a custom table or something. Until then, try one of these methods - https://stackoverflow.com/questions/285733/how-do-i-alter-the-position-of-a-column-in-a-postgresql-database-table
Stack Overflow
How do I alter the position of a column in a PostgreSQL database ta...
I've tried the following, but I was unsuccessful: ALTER TABLE person ALTER COLUMN dob POSITION 37;
user8923
user8923OPโ€ข3y ago
OK remote chance but I filed an enhancement https://github.com/supabase/supabase/issues/10149 Upvote if you find it useful! ๐Ÿ™
GitHub
Add the ability to change the position of table columns ยท Issue #10...
As my applications grow, I add new columns to tables and those are placed at the end of the list of columns. To ease development I like to keep related columns grouped. This also allows automated r...

Did you find this page helpful?