You can change the column name and change the column size in mysql. But can you rearrange the column order in mysql table. Yes, you can rearrange it in mysql. It can be done by 'ALTER', 'CHANGE' and 'AFTER' mysql command. The mysql query for move the column in mysql table is:
" ALTER TABLE table_name CHANGE column_name column_name datatype(length) AFTER column_name"
You can also done by 'MODIFY' mysql command. The mysql query as follows as:
" ALTER TABLE table_name MODIFY column_name datatype(length) AFTER column_name"
Consider the following example: table1 is the name of table.
Now the column 'name' is moved after column 'img'. The mysql query as follows as:
" ALTER TABLE table1 CHANGE name name varchar(30) AFTER img"
Now you'll get output like this:
The column name 'name' is placed after 'img' in mysql table 'table1'.
Now the order of table1 is changed like above output.
Related Post:
" ALTER TABLE table_name CHANGE column_name column_name datatype(length) AFTER column_name"
You can also done by 'MODIFY' mysql command. The mysql query as follows as:
" ALTER TABLE table_name MODIFY column_name datatype(length) AFTER column_name"
Consider the following example: table1 is the name of table.
Now the column 'name' is moved after column 'img'. The mysql query as follows as:
" ALTER TABLE table1 CHANGE name name varchar(30) AFTER img"
Now you'll get output like this:
The column name 'name' is placed after 'img' in mysql table 'table1'.
Move multiple columns at the time in mysql:
You can move multiple columns at the time in mysql. The column name order id, name ,img in table1 is changed into img, name ,id. The mysql query as follows as:
"ALTER TABLE table1 CHANGE id id int(5) AFTER img,
CHANGE name name varchar(30) AFTER img"
Now you'll get output like this:
Now the order of table1 is changed like above output.
Related Post:
Change column name in mysql
Change column size in mysql table
Delete column in mysql table
Add column after specific field in mysql table
Change column datatype in mysql
Change table name in mysql
Change column NOT NULL to NULL in mysql
Add primary key to existing column in mysql
how to add auto increment to existing column in mysql
How to remove auto increment from column in mysql
Change column size in mysql table
Delete column in mysql table
Add column after specific field in mysql table
Change column datatype in mysql
Change table name in mysql
Change column NOT NULL to NULL in mysql
Add primary key to existing column in mysql
how to add auto increment to existing column in mysql
How to remove auto increment from column in mysql