2

Assuming I have a table with a TEXT column, and there is data in it, what happens when I change that column from TEXT to MEDIUMTEXT, and is there something that I should be aware of or avoid?

Could there be any corruption or loss of data?


Note:

  • I'm converting from a smaller to a larger type. There should not be any truncation.
  • I'm aware of the lengths of the different types.
  • What I want to know is what happens during conversion and how does that affect data?

2 Answers2

1

You will have more characters allowed by row :

      Type | Maximum length
-----------+-------------------------------------
  TINYTEXT |           255 (2 8−1) bytes
      TEXT |        65,535 (216−1) bytes = 64 KiB
MEDIUMTEXT |    16,777,215 (224−1) bytes = 16 MiB
  LONGTEXT | 4,294,967,295 (232−1) bytes =  4 GiB
Till
  • 4,183
  • 3
  • 16
  • 18
1

See the answer here for maximum sizes for different column types. Since you're changing from smaller to bigger type, you don't need to worry about truncation. It's a safe operation. Also, you very probably have no index on that column, so not much to worry about there either.

Community
  • 1
  • 1
kaqqao
  • 12,984
  • 10
  • 64
  • 118