Example: Effects of Default and User-Specified Case Sensitivity on the Ordering of a Result Set - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
ft:locale
en-US
ft:lastEdition
2024-12-11
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

The following statements create and populate table t:

     CREATE TABLE t (
       a CHAR(4) NOT CASESPECIFIC,
       b BYTEINT)
     PRIMARY INDEX (a,b);
     INSERT INTO t VALUES ('AAAA', 1);
     INSERT INTO t VALUES ('aaaa', 2);
     INSERT INTO t VALUES ('BBBB', 3);
     INSERT INTO t VALUES ('bbbb', 4);

If the default handling of case is allowed, the following statement produces the following results table.

     SELECT *
     FROM t
     ORDER BY a;

Results table:

     a         b
     ----     ---
     AAAA      1
     aaaa      2
     BBBB      3
     bbbb      4

However, when you specify CASESPECIFIC for the query, the results are one of the results tables immediately following the example SELECT statements, depending on the collation sequence in effect for the current session.

     SELECT *
     FROM t
     ORDER BY CAST(a AS CASESPECIFIC);

or

     SELECT CAST(a AS CASESPECIFIC), b
     FROM t
     ORDER BY 1;
EBCDIC ASCII MULTINATIONAL
A B A B A B
aaaa 2 AAAA 1 aaaa 2
bbbb 4 BBBB 3 AAAA 1
AAAA 1 aaaa 2 bbbb 4
BBBB 3 bbbb 4 BBBB 3