Reputation: 7900
I created a table with couple of columns, and one of them is VARCHAR(250)
.
I have a lot of rows in the table and I want to change the DataType of the column to VARCHAR(500)
.
If I right-click on the table and select "alter table", I can change the column DataType.
Is it safe to change the DataType like this?
How else can I change the column DataType?
Is there is a possibility of losing data from the table when changing the DataType?
Upvotes: 0
Views: 1562
Reputation: 38645
If you are modifying the varchar(250)
to varchar(500)
then its safe to proceed. If you were changing from varchar(500)
to varchar(250)
then yes your data would be truncated. Also, if you were changing data types like varchar(250)
to integer
then yes that would also affect your data. You could use the graphical tool to modify your column or use the following statement from command line to alter your column:
alter table table_name modify column_name varchar(500);
or
alter table table_name change column_name column_name varchar(500);
Strongly suggest you to backup your table before doing this, just in case.
Upvotes: 5