If the maximum size of a field of type VARCHAR
is 65535 (occupies 65KB), it will always take up a 65KB space in the database for each line even if I put less text in it?
No, it will occupy essentially only the space occupied by the text. It’s a little more complicated than that, but it’s almost just that, just don’t think that if the text has 10 characters it will take 10 bytes. It depends on the encoding used, of the characters used effectively, has control information. Not to mention that there may be some other cost because of tricks that the database can use for optimizations. It will take more than 10 bytes, but not much more, maybe 30 at most. But if the text has 1000 characters depending on the case it will take 1012, for example.
Can use without fear. only the CHAR
is that it occupies the space, using or not.
See more.
Varchar no, see the answer of that question
– UzumakiArtanis
Did any of the answers solve your question? Do you think you can accept one of them? Check out the [tour] how to do this, if you haven’t already. You would help the community by identifying what was the best solution for you. You can accept only one of them. But you can vote on any question or answer you find useful on the entire site.
– Maniero