MySQL - How to increase varchar size of an existing column in a database without breaking existing data?

后端 未结 7 2052
渐次进展
渐次进展 2020-12-13 05:32

I have a column that is currently varchar(100) and I want to make it 10000.

is it as simple as

alter table table_name set          


        
相关标签:
7条回答
  • 2020-12-13 06:31

    It's safe to increase the size of your varchar column. You won't corrupt your data.

    If it helps your peace of mind, keep in mind, you can always run a database backup before altering your data structures.

    By the way, correct syntax is:

    ALTER TABLE table_name MODIFY col_name VARCHAR(10000)
    

    Also, if the column previously allowed/did not allow nulls, you should add the appropriate syntax to the end of the alter table statement, after the column type.

    0 讨论(0)
提交回复
热议问题