Reorder MySQL Table Column


Reorder MySQL Table Column? How can be happen? maybe we design a unperfect table in the first time, so we need to reorder the column.

It can be done easily by User Interface in SQL Yog,

Reorder MySQL Table, Reorder Column MySQL, Reorder Field MySQL 

Figure 1. Choose The Table

Reorder MySQL Table, Reorder Column MySQL, Reorder Field MySQL 
Figure 2. Choose the field to be Reorder.

 Reorder MySQL Table, Reorder Column MySQL, Reorder Field MySQL 
Figure 3. Field has been Reorder

Reorder MySQL Table, Reorder Column MySQL, Reorder Field MySQL 
Figure 4. Field Reorder Sucessfully


but there also any syntax can solve this problem :

ALTER table `tb_name`
MODIFY COLUMN `column_name` your_data_type
AFTER `other_column_name`

Just replace the following fields by your actual MySQL data:

* tb_name: the name of your MySQL table being modified.
* column_name: the name of the MySQL table column that you want to reorder.
* your_data_type: the MySQL data type of the data stored in the moved column, such as int, varchar(lenght), text, etc.
* other_column_name: the column name that will be just before the new position of your reordered column.


This will reorder the columns in your current MySQL table structure, but it will not alter the row order of your table records: the stored data order will remain unaltered. Reorder MySQL table columns to visually group strongly related fields. So reordering is just a way of changing the column order of an existing MySQL table, and it won't modify your query performance.

Column reorder is mainly a matter of coherence and logical organization. On the contrary, altering the stored data order may optimize (or negatively impact) such MySQL query performance.

Example by Using Syntax :

I Have a Table

CREATE TABLE `guest_book` (                             
              `id_gb` int(4) NOT NULL AUTO_INCREMENT,               
              `pengirim` varchar(20) NOT NULL DEFAULT '',           
              `email` varchar(50) NOT NULL DEFAULT '',              
              `isi` text NOT NULL,  
              `tgl1` datetime DEFAULT NULL,                              
              `tgl` datetime DEFAULT NULL,                    
              PRIMARY KEY (`id_gb`)                                 
            )

and then i use DDL syntax :

ALTER table `guest_book`
MODIFY COLUMN `tgl1` timestamp
AFTER `tgl`


(4 row(s)affected)
(0 ms taken)

You Can Check The Difference Here..



Please beware of changing datatype after the field name in second line syntax.

Komentar FB


Probably Related Article



30 comments:

!Rchymera! said...
February 11, 2010 at 11:11 AM

Wach betah gw berada disini selalu ada info dan ilmu2 baru,thanks for share and always succes for you my friend...:D

Anonymous said...
February 13, 2010 at 5:25 AM

Great post as for me. I'd like to read more concerning that theme. The only thing it would also be great to see here is a few pics of any gadgets.
Jeff Trider
Phone jammers

rumah blogger said...
February 15, 2010 at 3:31 AM

nice info sob..

sabirinnet said...
February 15, 2010 at 3:32 AM

saya hanya bisa memanadang sambil manggut-manggut nich, hehehe sukses ya mas

Wong jadul said...
February 17, 2010 at 2:18 PM

Blognya keren,artikelnya keren,dan pastinya orangnya juga keren...:D

Semoga sukses kawan...:D

donor insemination said...
February 24, 2010 at 5:32 PM

Very useful information provided and get more information.

SQL Server Tutorial said...
August 5, 2010 at 12:29 AM

Nice tips, keep writing great articles friend

costume jewelry said...
September 19, 2010 at 12:33 PM

Thanks mate, I was lost really useful info. 5* Well recommended. Thanks

Mr. Parts said...
January 7, 2011 at 2:20 PM

Great info. Thank you!

Phone Sex said...
May 5, 2011 at 8:36 PM

Nice post......it is a great way to get the back links of the site to increase the visibility of site in SERP. . Keep up the good work!

Phone Sex said...
May 10, 2011 at 11:10 PM

That a very nice article. I get complete information about the hidden camera from this article. So thank you very much to posting me such a wonderful article. For the more information visit on www(dot)sunsecurity(dot)com.

German silver said...
May 10, 2011 at 11:10 PM

Awesome article! I have gradually become fan of your article and would like to suggest putting some new updates to make it more effective.

Fuel_Saver said...
May 11, 2011 at 6:42 AM

Great article. Thanks for sharing

LED_Lights_Man said...
June 24, 2011 at 11:07 AM

nice info sob..

OBD_Scanner said...
June 30, 2011 at 9:12 AM

saya hanya bisa memanadang sambil manggut-manggut nich, hehehe sukses ya mas

Car_Parts_Man said...
July 8, 2011 at 3:14 PM

nice info sob..

web design company said...
July 12, 2011 at 9:50 PM

Hi..Great post as for me. I'd like to read more concerning that theme. The only thing it would also be great to see here is a few pics of any gadgets.

Super_Flux_LEDs said...
July 15, 2011 at 10:18 AM

That a very nice article. I get complete information about the hidden camera from this article. So thank you very much to posting me such a wonderful article. For the more information visit on www(dot)sunsecurity(dot)com.

Mr LED Strobe Lights said...
July 22, 2011 at 12:35 PM

nice info sob..

LED Lights for Homes said...
July 29, 2011 at 3:09 PM

saya hanya bisa memanadang sambil manggut-manggut nich, hehehe sukses ya mas

Dodge_Ram_Parts said...
August 5, 2011 at 12:44 PM

saya hanya bisa memanadang sambil manggut-manggut nich, hehehe sukses ya mas

Philips _Xenon_HID said...
August 14, 2011 at 10:56 AM

nice info sob..

HID_Lights_Bulbs said...
August 22, 2011 at 7:46 AM

nice info sob, it was very nice again

Electric_Supercharger said...
August 28, 2011 at 11:30 AM

Blognya keren,artikelnya keren,dan pastinya orangnya juga keren...:D

Hidlight_Accessories_HID said...
September 2, 2011 at 9:00 AM

Great info for sure. Keep it up

Complete_HID_Kits said...
September 11, 2011 at 10:42 AM

Wach betah gw berada disini selalu ada info dan ilmu2 baru,thanks for share and always succes for you my friend...:D

BMW_Accessories said...
September 18, 2011 at 10:25 AM

saya hanya bisa memanadang sambil manggut-manggut nich, hehehe sukses ya mas

KVM Switches said...
February 7, 2012 at 10:23 PM

How exciting, I will certainly take a look at this table and I see that nobody has lost their passion. Please keep up your amazing work here and Thanks for making me conscious about this.

website marketing company said...
March 25, 2012 at 3:29 AM

I always like to know some important things. So i adhere to this site for collecting some important and useful article for post and sharing with some of my friends. I like this article. its so nice.

LEDKITguy said...
May 4, 2015 at 2:42 PM

Thank you for sharing this information. Please post more

Related Posts by Categories



Widget by