shamsuljewel Posted October 25, 2007 Share Posted October 25, 2007 I want to move 2 col after 5th col how do I do it? please let me know.. Quote Link to comment https://forums.phpfreaks.com/topic/74695-how-to-change-the-col-position-of-a-table/ Share on other sites More sharing options...
rajivgonsalves Posted October 25, 2007 Share Posted October 25, 2007 the syntax something like this ALTER TABLE table_name MODIFY column_name column_type AFTER column_name_after Quote Link to comment https://forums.phpfreaks.com/topic/74695-how-to-change-the-col-position-of-a-table/#findComment-377661 Share on other sites More sharing options...
fenway Posted October 25, 2007 Share Posted October 25, 2007 the syntax something like this ALTER TABLE table_name MODIFY column_name column_type AFTER column_name_after This won't work -- don't even try and move a column!!! Quote Link to comment https://forums.phpfreaks.com/topic/74695-how-to-change-the-col-position-of-a-table/#findComment-377835 Share on other sites More sharing options...
toplay Posted October 25, 2007 Share Posted October 25, 2007 shamsuljewel, there's no real good reason to have to move columns around. It doesn't really matter in RDBMS/SQL (since you can retrieve the data in any order). rajivgonsalves has the right syntax to do that. That will work. fenway, I don't know why you state that will not work? Quote Link to comment https://forums.phpfreaks.com/topic/74695-how-to-change-the-col-position-of-a-table/#findComment-377886 Share on other sites More sharing options...
fenway Posted October 25, 2007 Share Posted October 25, 2007 fenway, I don't know why you state that will not work? It shouldn't work... it shouldn't even be allowed. Quote Link to comment https://forums.phpfreaks.com/topic/74695-how-to-change-the-col-position-of-a-table/#findComment-378040 Share on other sites More sharing options...
toplay Posted October 25, 2007 Share Posted October 25, 2007 fenway, I don't know why you state that will not work? It shouldn't work... it shouldn't even be allowed. Didn't really answer my question, but oh well. It works. Also, don't understand why you say it shouldn't be allowed. Basically, I don't understand where you're coming from...please elaborate (if you want). Quote Link to comment https://forums.phpfreaks.com/topic/74695-how-to-change-the-col-position-of-a-table/#findComment-378047 Share on other sites More sharing options...
fenway Posted October 25, 2007 Share Posted October 25, 2007 fenway, I don't know why you state that will not work? It shouldn't work... it shouldn't even be allowed. Didn't really answer my question, but oh well. It works. Also, don't understand why you say it shouldn't be allowed. Basically, I don't understand where you're coming from...please elaborate (if you want). There's no reason to do so -- just like trying to fiddle with the auto-increment counter. It means you're trying to do something you should not ever need to do. Quote Link to comment https://forums.phpfreaks.com/topic/74695-how-to-change-the-col-position-of-a-table/#findComment-378086 Share on other sites More sharing options...
toplay Posted October 26, 2007 Share Posted October 26, 2007 There's no reason to do so -- just like trying to fiddle with the auto-increment counter. It means you're trying to do something you should not ever need to do. Yes, fenway, Of course I generally agree with you. However, it's sometimes nice to have column data next to certain other related column data. I know, I know, all the data in a table should be related, yes; but I'm referring to something like adding a new fax number column next to a phone number column, adding a new second address column next to the main/first address column. Also, it's nice to have most viewed data created in the first few columns of a table if for nothing else but to make the data easily viewable in programs such as SQLyog without having to horizontally scroll all the time. Sometimes, it's just dictated by the company you're working for and their lead programmer, DBA, or architect. As for changing the auto-increment value, I've had the need to change it in a development environment. I think I've had to change it once in a production environment but I can't really remember. So, there's no need to move columns or change auto increment values 99% of the time folks. Quote Link to comment https://forums.phpfreaks.com/topic/74695-how-to-change-the-col-position-of-a-table/#findComment-378760 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.