Specifies case for character data comparisons and collations.
CASESPECIFIC is a Teradata extension to the ANSI SQL:2011 standard.
The following set of rules applies to CASESPECIFIC and NOT CASESPECIFIC in both ANSI and Teradata modes.
Note that the performance of views, macros, and CHECK table constraints can involve parsing character string literals at execution time as well as the more common processing of character string literals in queries.
For more information, see “The SELECT Statement” in SQL Data Manipulation Language.
The following rules apply to CASESPECIFIC and NOT CASESPECIFIC in Teradata mode.
You can override this default in a query by specifying (CASESPECIFIC) immediately following the CHARACTER data to be compared.
For example, the following query is not case specific in Teradata mode:
SELECT DataBaseName
FROM DBC.Databases
WHERE DataBaseName = 'dbc';
To make it case specific, qualify the predicate with (CASESPECIFIC):
SELECT DataBaseName
FROM DBC.Databases
WHERE DataBaseName = 'dbc' (CASESPECIFIC);
Note that the first example returns one row and the second example returns no rows.
The following rules apply to CASESPECIFIC and NOT CASESPECIFIC in ANSI mode.
For more information on UPPER, see SQL Functions, Operators, Expressions, and Predicates.
If you declare a character column to be NOT CASESPECIFIC and type ‘’ (GREEK SMALL LETTER ALPHA TONOS), then that letter is stored as ‘
’ but during comparison compares equal to ‘'Α’ (GREEK CAPITAL LETTER ALPHA TONOS).
The same applies to the (NOT CASESPECIFIC) qualifier in a SQL predicate.
The following SQL predicate evaluates to TRUE.
'
'
(NOT CASESPECIFIC) =
'
'Α'
Without the (NOT CASESPECIFIC) qualifier, the same predicate evaluates to FALSE.
The following table summarizes case criteria and issues.
IF the case specification is … |
THEN … |
CASESPECIFIC (CS) |
In sorts or comparisons, lowercase characters are not converted to uppercase and are not equal to uppercase characters. For an example, see “Example 1” on page 220. |
NOT CASESPECIFIC (NOT CS) |
In sorts or comparisons, lowercase characters are converted to uppercase. ‘aaa’ is equivalent to ‘AAA’. ’AAA’, ’aaa’, ’AaA’, and ’aAA’ are all equivalent as unique indexes. |
Neither CASE SPECIFIC nor NOT CASESPECIFIC |
The session mode determines the attribute assigned by default. |
The following query returns a result only if a case specific comparison of the literal ‘Leidner P’ finds a match.
SELECT Name
FROM Employee
WHERE Name(CS) = 'Leidner P' ;
The literal ‘Leidner P’ might default to CS or NOT CS, depending on the current mode, but because the type modifier of the comparison is CS, the comparison is case specific irrespective of the session mode.
To ensure a comparison that is not case specific irrespective of the session mode, specify the query as follows.
SELECT Name
FROM Employee
WHERE Name (NOT CS) = 'Leidner P' (NOT CS) ;
Alternatively, you can specify the query using ANSI-compatible syntax as follows.
SELECT Name
FROM Employee
WHERE UPPER (Name) = 'LEIDNER P' ;
CASESPECIFIC comparison and collation on mixed case data can produce unintended results.
SELECT Last_Name
FROM SalesReps
ORDER BY Last_Name(CS) ;
might return one of the following sorted lists depending on the collation in effect for the session.
EBCDIC |
ASCII |
MULTINATIONAL |
bart |
ACME |
ACME |
fernandez |
ALBERT |
Albert |
hill |
Albert |
ALBERT |
Albert |
FARRAH |
bart |
ACME |
Kimble |
FARRAH |
ALBERT |
bart |
fernandez |
FARRAH |
fernandez |
hill |
Kimble |
hill |
Kimble |