jeudi 1 mai 2014

MySQL - char(17) vs varchar(17) pour une déclaration de type latin - Stack Overflow


I have a database table that stores images. The acceptable types are jpg/png/gif/ and the name is always going to have 13 characters.


In other words, the filename length is always going to be 17 characters long (13 for the name + the ‘.’ + the extension).


For all that I’ve read in here, I believe that I should declare it as a char because it takes less space.


Here’s my 2 questions:



  • Assuming that my filename is always going to be latin1 type, not utf8, is it true that a char(17) takes less bytes then a varchar(17)?

  • If yes, how many? (i’m actually not sure how to calculate the bytes in a char and varchar)


Thanks



I have a database table that stores images. The acceptable types are jpg/png/gif/ and the name is always going to have 13 characters.


In other words, the filename length is always going to be 17 characters long (13 for the name + the ‘.’ + the extension).


For all that I’ve read in here, I believe that I should declare it as a char because it takes less space.


Here’s my 2 questions:



  • Assuming that my filename is always going to be latin1 type, not utf8, is it true that a char(17) takes less bytes then a varchar(17)?

  • If yes, how many? (i’m actually not sure how to calculate the bytes in a char and varchar)


Thanks


0 commentaires:

Enregistrer un commentaire