First of all, keep in mind that the length of the database can be really in characters, not in bytes - you will need to check the documentation for the data type. I am going to suggest that this is indeed the last for the purpose of the question.
The number of bytes that your string will use depends entirely on the character encoding with which it will be stored. If it is UTF-16, the default string type in Delphi, then it will always be 2 bytes per character, excluding surrogates.
Most likely, encoding, assuming the database uses Unicode encoding, is UTF-8. This is variable-length encoding: depending on the character, characters may require 1 to 4 bytes. You can see a diagram on Wikipedia about how ranges are displayed.
However, if you do not change the database schema at all, this should mean one of three things:
- Currently, you store everything in binary, not in a textual way (usually this is not a good choice).
- The database already stores Unicode and counted characters, not bytes (otherwise you would have a problem now, moreover, in the case of letters with an accent)
- The database is stored in a single-byte code page, such as Windows-1252, not allowing you to store Unicode data at all (which makes it invalid because the characters will be stored the same as before, t use Unicode)
I am not familiar with Oracle, but if you look at MSSQL, they have two different data types: varchar and nvarchar. Varchar is counted in bytes, and nvarchar is counted in characters, so it is suitable for Unicode. MySQL, on the other hand, has only varchar, and it is always counted in characters (starting with 4.1). Therefore, you should check the Oracle documentation and database schema to get a decisive answer to the question whether this is really a problem.
source share