Reputation: 11
I have created a table in mysql. In the table I defined earlier a type int for "Phone number" but it's throwing an error while entering the phone number that: "ERROR 1265 (01000): Data truncated for column 'phone' at row 1".
So I tried to change the type of the field Phone from 'int' to 'varchar' but I am not able to change.
I know we can use ALTER command like I tried - "ALTER TABLE student(table name) COLUMN MODIFY varchar"
However, it is modifying the type of whole column while I just want to change the type of a particular cell/row.
Upvotes: 1
Views: 308
Reputation: 415
Use this commands.
USE dbname;
ALTER TABLE table1 CHANGE phonenumber phonenumber varchar(255);
or
USE dbname;
ALTER TABLE table1 MODIFY phonenumber1 varchar(25);
Upvotes: 1
Reputation:
You can use the below SQL ALTER statement to modify your column type as:
alter table cell_info modify nums varchar(20);
Example: create table cell_info(id int, nums int); insert into cell_info values(1,12341234); alter table cell_info modify nums varchar(20); insert into cell_info values(1,'My new number');
select * from cell_info;
Upvotes: 0