Link to home
Start Free TrialLog in
Avatar of bolicat
bolicat

asked on

datatype how many bytes does each char map to

datatype how many bytes does each char map to
VARCHAR2
NVARCHAR2
CHAR
NCHAR
NUMBER
PLS_INTEGER
RAW
ASKER CERTIFIED SOLUTION
Avatar of jasonwisdom
jasonwisdom

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Lowfatspread
The answer depend on the DBMS you are working with...

in general

char's use 1 byte per defined length
nchar's use 2 bytes per defined length character
both the above are "Fixed" length

Varchar/NVarchar  have a maximum length defined (and use either 1 or 2 bytes per character)
    there is also a length overhead for variable length columns which is normally 2 bytes for lengths under 4096
    and then will be 4 bytes above...
     (Only the actual used length of the column will be stored)

another modification / factor is whether the column is nullable or not
if null then typically a bit flag in the row will be used to indicate wether the column is null or not (so 1 byte per 8 nullable columns)... I think some DBMS use a similar idea for columns with default values...

so it really does depend on the DBMS (& OS and Version ) your using...