3

I created a table named items and inserted name as int and provided the length as 255 type by mistake but now i wanted to alter the table structure and run the query as--

ALTER TABLE items ALTER COLUMN name varchar(255); but it is not altering the table what i need to change in the table.help plz

swapnesh
  • 26,318
  • 22
  • 94
  • 126

3 Answers3

22

there are two ways

ALTER TABLE t1 CHANGE <column_name> <column_name> <type> 

note: you have to write column name twice OR

ALTER TABLE t1 MODIFY <column_name> <type> ;

Reference

xkeshav
  • 53,360
  • 44
  • 177
  • 245
2

try:

alter table t1 modify column name varchar(255);
neocanable
  • 5,293
  • 2
  • 23
  • 28
1

Try:

ALTER table items
MODIFY name varchar(255);
royrui
  • 1,217
  • 10
  • 20