Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rearrange the column position in MySQL [closed]

How can I change the column position to first using ALTER query in MySQL table?

like image 626
tyro Avatar asked Nov 29 '25 12:11

tyro


1 Answers

If you want your column at first position, you should use

ALTER TABLE tableName MODIFY COLUMN yourColumnName varchar(50) FIRST 

For example, if your table is

Employee{FirstName,LastName,EmpId}

And if you want to move EmpId to first position

ALTER TABLE Employee MODIFY COLUMN EmpId varchar(15) FIRST;
like image 197
anbuj Avatar answered Dec 02 '25 04:12

anbuj



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!