(N)VARCHAR
DATATYPES
Purpose
Use the VARCHAR and NCHAR VARYING datatypes to
hold text values of a variable length.
Syntax
<varchar_type>
::= <varchar_keyword> (
<psql_integer> ) [ <char_set> ] |
<nvarchar_keyword> ( <psql_integer> )
<varchar_keyword>
::= CHARACTER VARYING |
VARCHAR
<nvarchar_keyword> ::= NCHAR
VARYING | NATIONAL CHARACTER VARYING |
NATIONAL CHAR VARYING
<char_set> ::= CHARACTER
SET <identifier>
Semantics
The VARCHAR(n) datatype contains text of varying
length, up to a maximum of n characters. The maximum size is 32,767
bytes, which can be 10,992 to 32,767 characters, depending on the
character size (1..3 bytes). You must supply n; there is no default
to 1.
Firebird converts from variable-length character
data to fixed-length character data by adding spaces to the value in
the varying column until the column reaches its maximum length n. In
the reverse conversion, trailing blanks are removed from the text.
The main advantage of using the VARCHAR(n)
datatype are that it saves memory space during the execution of PSQL
programs.
Examples
The below examples define a type to hold 32
characters in Unicode and a type to hold 128 characters in the
ISO8859_1 character set (a.k.a. “latin1”):
VARCHAR(32) CHARACTER SET
UNICODE_FSS NCHAR VARYING (128)
See also
Character sets and collation orders in the SQL
Reference Manual
|