View Definitions and Character Sets - Analytics Database - Teradata Vantage

SQL Data Definition Language Detailed Topics

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2023-07-11
dita:mapPath
vuk1628111288877.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
B035-1184
lifecycle
latest
Product Category
Teradata Vantage™

A view can contain explicit [VAR]CHARACTER(n) [CHARACTER SET …] clauses. If the server character set (for example, CHARACTER SET LATIN) is not specified, the view definition expands the [VAR]CHARACTER(n) clause to include that specification.

Expansion is done according to the following rules:

  • If the clause is applied to an expression within the body of the view, it takes the server character set of the expression if the expression is of type CHARACTER.
  • Otherwise, the server character set is set to the default character set of the creator/modifier of the view.

    The default session character set of the creating user of the view is used because otherwise the user default session character set would depend on each individual user, and two users with different default session character sets could get different results from the view.

    For example, if the CREATE USER default character set is Kanji1, then the view is expanded as follows:

    Original view definition:

        CREATE TABLE table_1 (
          cu CHARACTER(5) CHARACTER SET  UNICODE);
           
        CREATE VIEW view_1 AS
         SELECT cu (CHARACTER(6))
         FROM table_1;

    Expanded view definition:

        CREATE VIEW v1 AS
         SELECT cu (CHARACTER(6), CHARACTER SET  UNICODE)
         FROM table_1;

    Similarly, the following view definition is expanded as follows:

    Original view definition:

        CREATE VIEW v2 AS
         SELECT 123 (CHARACTER(12));

    Expanded view definition:

        CREATE VIEW v2 AS
         SELECT 123 (CHARACTER(12), CHARACTER SET KANJI1);