How to change column type from varchar (30) to varcahar (100)?

I have a table that describes how this:

mysql> describe easy_table; +---------------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------------------+--------------+------+-----+---------+----------------+ | id | bigint(20) | NO | PRI | NULL | auto_increment | | version | bigint(20) | NO | | NULL | | | account_id | bigint(20) | NO | MUL | NULL | | | city | varchar(30) | NO | | NULL | | ... | name | varchar(255) | YES | | NULL | | | name_two | varchar(255) | YES | | NULL | | +---------------------+--------------+------+-----+---------+----------------+ 13 rows in set (0.03 sec) 

I am trying to make varchar city bigger than varchar (100) and this line is not working

 alter table easy_table alter column city varchar(100); 

it doesn't work either

 alter table easy_table alter column city varchar(100) not null; 

I get this error:

ERROR 1064 (42000): You have an error in the SQL syntax; check the manual that matches your version of MySQL server to find the correct syntax to use next to 'varchar (100)' on line 1

+7
source share
4 answers
 alter table easy_table modify column city varchar(100) not null; 
+22
source

Use the Modify keyword, not Alter

+1
source

try

 alter table easy_table change city city varchar(100); 
0
source
 alter table easy_table modify city VARCHAR(100) ; 

There should be a command to resize the column.

Please refer to this page .. This is a useful link ..

http://php.about.com/od/learnmysql/p/alter_table.htm

0
source

Source: https://habr.com/ru/post/889075/


All Articles