Home » SQL & PL/SQL » SQL & PL/SQL » varchar2 byte or char semantics (db any version)
varchar2 byte or char semantics [message #676299] Wed, 29 May 2019 03:18 Go to previous message
John Watson
Messages: 8930
Registered: January 2010
Location: Global Village
Senior Member
I have never really bothered about this before: I've always accepted the default (which I know can be changed at various levels) of BYTE. However, I've just been asked about it and can't come up with an answer.

I may be wrong, but I think this is how it works:

BYTE is a defined maximum length. If using unicode AL32UTF8 (assume this from now on) it may not be possible to fit that number of characters in the column.
CHAR is a defined maximum number of characters, and the number of bytes they will take up could be more than that: worst case, four times as many. There will be errors if the number of bytes goes over 4000, even if the number of CHARs has not been exceeded.

For several releases the nvarchar2 character set has been fixed length AL16UTF16, so does not have a choice.

What I'm hoping for is a general rule (which would of course have any number of exceptions) as to when to use BYTE and when to use CHAR. Any advice?

--update: this is particularly in regard to APEX.

Thank you for any insight.

[Updated on: Wed, 29 May 2019 03:31]

Report message to a moderator

 
Read Message
Read Message
Read Message
Previous Topic: json filter unusual behaviour
Next Topic: How to write SQL Query to get desire output
Goto Forum:
  


Current Time: Tue Apr 23 17:20:09 CDT 2024