I've cast a column value as VARCHAR2(9) in my query to make it as a varchar2() that hold 9 characters.
It's been suggested to me that VARCHAR2(10) works better and should be a solution to any requirement that asks for VARCHAR2 capable of holding 9 characters.
Expert advice?
VARCHAR2(9 BYTE)
.VARCHAR2(9 CHAR)
.VARCHAR2(10 BYTE)
.VARCHAR2(10 CHAR)
.We can't advise you what to use but if you only want 9 characters then use
VARCHAR2(9 BYTE)
orVARCHAR2(9 CHAR)
(as appropriate for the type of characters you will be storing).I suggest you get that person to explain why they are suggesting adding another character; because if you only need to store 9 characters then specifying a limit of 10 seems to be wrong.
For example:
If you have the table:
And try to insert 9 unicode characters (at 3-bytes each):
An exception is raised:
However:
Works without error and inserts the 9 unicode characters.
db<>fiddle here