Search code examples
sqlmysqlvarcharnull-terminated

[My]SQL VARCHAR Size and Null-Termination


Disclaimer: I'm very new to SQL and databases in general.


I need to create a field that will store a maximum of 32 characters of text data. Does "VARCHAR(32)" mean that I have exactly 32 characters for my data? Do I need to reserve an extra character for null-termination?

I conducted a simple test and it seems that this is a WYSIWYG buffer. However, I wanted to get a concrete answer from people who actually know what they're doing.


I have a C[++] background, so this question is raising alarm bells in my head.


Solution

  • Yes, you have 32 characters at your disposal. SQL does not concern itself with nul terminated strings like some programming languages do.