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

SQL Data Manipulation Language

Product
Teradata Database
Teradata Vantage NewSQL Engine
Release Number
16.20
Published
March 2019
Language
English (United States)
Last Update
2019-05-03
dita:mapPath
fbo1512081269404.ditamap
dita:ditavalPath
TD_DBS_16_20_Update1.ditaval
dita:id
B035-1146
lifecycle
previous
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;
     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