Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update a column of char type in mysql to increase its length

Tags:

syntax

sql

mysql

How to increase the length of a column with char data type in mysql ?

The following query

ALTER TABLE tablename ALTER COLUMN columnname varchar(30) not null;

is not working.

Point out my error please. Thanks

like image 788
codeofnode Avatar asked Oct 19 '12 11:10

codeofnode


2 Answers

ALTER TABLE `tablename` CHANGE `columnname` `columnname` VARCHAR( 30 ) NOT NULL 

OR

ALTER TABLE `tablename` MODIFY `columnname` VARCHAR( 30 ) NOT NULL 
like image 124
PyQL Avatar answered Sep 19 '22 23:09

PyQL


please try query given below

ALTER TABLE tablename  MODIFY  columnname varchar(30) NOT NULL;  

You can refer to this tutorial

like image 34
Er. Anurag Jain Avatar answered Sep 20 '22 23:09

Er. Anurag Jain