Joy
Joy

Reputation: 287

Mysql 5 - how many characters can be stored with utf8mb4_unicode_ci?

Assuming I have a varchar(250) and a TEXT field. How many characters (if they have all the maximum size, I think 4 bytes?) can be stored in the first field and in the second field if their encoding is utf8mb4_unicode_ci?

Upvotes: 2

Views: 845

Answers (1)

Shadow
Shadow

Reputation: 34231

varchar(250) can store up to 250 characters, since the length restriction is applied on the number of characters, not bytes. The overall row length restriction is applied on byte level, however, 250 *4 is only 1000, which is a far cry from the limit of 65,535.

Text columns can hold up to 2^16-1 bytes of data. Since you assumed that each character takes up the maximum 4 bytes, a simple division will give you the maximum number of characters.

Upvotes: 2

Related Questions