Casting to a Domain
When you cast to a domain, any constraints declared for it are taken into account, i.e. NOT NULL
or CHECK
constraints.If the value does not pass the check, the cast will fail.
If TYPE OF
is additionally specified — casting to its base type — any domain constraints are ignored during the cast.If TYPE OF
is used with a character type (CHAR
/VARCHAR
), the character set and collation are retained.