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

SQL Data Manipulation Language

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2025-04-02
dita:mapPath
pon1628111750298.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
esx1472246586715
lifecycle
latest
Product Category
Teradata Vantageā„¢

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;

Result:

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

On the other hand, 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