例: CASE_N関数を使用したCHARACTERパーティション - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQLデータ定義言語 構文規則および例

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
2021年7月
Language
日本語
Last Update
2021-09-23
dita:mapPath
ja-JP/spp1591731285373.ditamap
dita:ditavalPath
ja-JP/wrg1590696035526.ditaval
dita:id
B035-1144
Product Category
Software
Teradata Vantage

以下の例では、CASE_N関数に基づくパーティション化式を使用して文字パーティションを指定します。この例では、CASE_N関数にLIKE演算子が含まれるので、静的行パーティション排除はサポートされていません。<Teradata Vantage™ - SQLリクエストおよびトランザクション処理、B035-1142>を参照してください。

     CREATE TABLE accounts (
       cust_id     INTEGER, 
       last_name   VARCHAR(30) CHARACTER SET UNICODE NOT CASESPECIFIC, 
       first_name  VARCHAR(30), 
       city        VARCHAR(50))
     PRIMARY INDEX (cust_id)
     PARTITION BY CASE_N (last_name LIKE ‘A%’,
                          last_name LIKE ‘B%’,
                          last_name LIKE ‘C%’,
                          last_name LIKE ‘D%’,
                          last_name LIKE ‘E%’,
                          last_name LIKE ‘F%’,
                          last_name LIKE ‘G%’,
                          last_name LIKE ‘H%’,
                          last_name LIKE ‘I%’,
                          last_name LIKE ‘J%’,
                          last_name LIKE ‘K%’,
                          last_name LIKE ‘L%’,
                          last_name LIKE ‘M%’,
                          last_name LIKE ‘N%’,
                          last_name LIKE ‘O%’,
                          last_name LIKE ‘P%’,
                          last_name LIKE ‘Q%’,
                          last_name LIKE ‘R%’,
                          last_name LIKE ‘S%’,
                          last_name LIKE ‘T%’,
                          last_name LIKE ‘U%’,
                          last_name LIKE ‘V%’,
                          last_name LIKE ‘W%’,
                          last_name LIKE ‘X%’,
                          last_name LIKE ‘Y%’,
                          last_name LIKE ‘Z%’,
                          NO CASE,
                          UNKNOWN);

以下の例では、CASE_N関数にLIKE演算子が含まれないので、静的行パーティション排除がサポートされ、テーブルに対するクエリーのパフォーマンスが向上します。

     CREATE TABLE accounts (
       cust_id     INTEGER, 
       last_name   VARCHAR(30) CHARACTER SET UNICODE NOT CASESPECIFIC, 
       first_name  VARCHAR(30), 
       city        VARCHAR(50))
     PRIMARY INDEX (cust_id)
     PARTITION BY  CASE_N (last_name < 'A', last_name < 'B',
                           last_name < 'C', last_name < 'D',
                           last_name < 'E', last_name < 'F',
                           last_name < 'G', last_name < 'H',
                           last_name < 'I', last_name < 'J',
                           last_name < 'K', last_name < 'L',
                           last_name < 'M', last_name < 'N',
                           last_name < 'O', last_name < 'P',
                           last_name < 'Q', last_name < 'R',
                           last_name < 'S', last_name < 'T',
                           last_name < 'U', last_name < 'V',
                           last_name < 'W', last_name < 'X',
                           last_name < 'Y', last_name >= 'Z',
                           UNKNOWN);