3. Understanding SQL Data Types : SQL Data Types : Character Data Types : Char Data Type
 
Share this page                  
Char Data Type
Fixed-length char strings can contain any printing or non-printing character, and the null character ('\0'). In uncompressed tables, char strings are padded with blanks to the declared length. (If the column is nullable, char columns require an additional byte of storage.) For example, if ABC is entered into a char(5) column, five bytes are stored, as follows:
'ABC  '
Leading and embedded blanks are significant when comparing char strings. For example, the following char strings are considered different:
'A B C'
'ABC'
When selecting char strings using the underscore (_) wildcard character of the LIKE predicate, include any trailing blanks to be matched. For example, to select the following char string:
'ABC '
the wildcard specification must also contain trailing blanks:
'_____'
Length is not significant when comparing char strings; the shorter string is (logically) padded to the length of the longer. For example, the following char strings are considered equal:
'ABC'
'ABC '
Note:  A synonym for char is character.