Alter Table Data Type

I created a table called items and inserted the name as int and provided the length as 255 type by mistake, but now I wanted to change the structure of the table and run the query as -

Elements ALTER TABLE ALTER COLUMN name varchar (255); but this does not change the table, what I need to change in the .help plz table

+3
source share
3 answers

There are two ways:

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

Note: you need to double-write the column name OR

ALTER TABLE t1 MODIFY <column_name> <type> ;

Link

+20
source

to try:

alter table t1 modify column name varchar(255);
+2
source

Try:

ALTER table items
MODIFY name varchar(255);
+1
source

All Articles