I'm considering how to store the maximum number of characters between 300 and 500 characters in VARCHAR type.
Is the maximum number of characters stored and the number of bytes required not completely correlated?
Do VARCHAR(1) and VARCHAR(255) have the same 1 byte space that can store different characters but retains the same number of characters?
If it is →, can I interpret that it is better to set it to VARCHAR(255)?
Are VARCHAR(256) and VARCHAR(65,535) two bytes of space that can store different characters but holds the same number of characters?
If it is →, can I interpret that it is better to set it to VARCHAR (65,535)?
後 It is troublesome to change the setting later, so I thought it would be better to set the maximum number of characters for the same number of bytes in advance.
MySQL 5.7
InnoDB
utf8mb4_general_ci
I'm not sure what makes me think that I should set it to VARCHAR (255), but the manual says the following, so why don't you use this as a judgment?
The VARCHAR value is stored as data with a 1-byte or 2-byte length prefix.The length prefix indicates the number of bytes included in the value.Use 1-byte length prefixes for columns containing values less than or equal to 255 bytes, and 2-byte length prefixes for columns containing values greater than 255 bytes.
© 2024 OneMinuteCode. All rights reserved.