- The CHAR datatype is used to hold fixed-length character string data.
- A CHAR string always contains the maximum number of characters.
- Strings shorter than the maximum length are padded with spaces.
- The CHAR datatype typically uses 1 byte per character.
- The CHAR datatype has a maximum length of 32767 bytes.
The Syntax for the CHAR Datatype
variable_name is whatever you want to call the variable.
size is the size, in bytes, of the string.
Here are some examples:
employee_name := 'James Gennick';
employee_name := 'Jeff Gennick';
Because CHAR variables are fixed length and the preceding strings are each less than 32 characters long, they will be right-padded with spaces.
Thus the actual values in employee_name would be
When doing string comparisons, the trailing spaces count as part of the string.
Oracle has one subtype defined for the CHAR datatype, and it is called CHARACTER.
It has exactly the same meaning as CHAR.