疑似列の使用方法

疑似列は、列と同じコンテキストで使用される割当て値ですが、格納されていません。疑似列は、表の実際の列ではありませんが、列と同じように動作します。疑似列では、選択操作を実行できますが、挿入、更新または削除操作は実行できません。

replicaSetId#疑似列を使用して、行が格納されているレプリカ・セットを判断します。この疑似列は、NOT NULL TT_INTEGERデータ型を返します。

TimesTen Scaleoutでサポートされているその他の疑似列の詳細は、『Oracle TimesTen In-Memory Database SQLリファレンス』TimesTen Scaleoutの疑似列を参照してください。

次の例があります。

replicaSetId#を使用したデータの検索

この例では、customers表に対する問合せを発行し、データが格納されているレプリカ・セットを返します(replicaSetId#により決定される)。

Command> SELECT replicasetid#, cust_id,last_name,first_name 
         FROM customers WHERE cust_id BETWEEN 910 AND 920
         ORDER BY cust_id, last_name, first_name;
< 2, 910, Riley, Tessa >
< 1, 911, Riley, Rashad >
< 1, 912, Riley, Emma >
< 1, 913, Rivera, Erin >
< 1, 914, Roberts, Ava >
< 1, 915, Roberts, Lee >
< 2, 916, Roberts, Clint >
< 3, 917, Robertson, Faith >
< 2, 918, Robinson, Miguel >
< 2, 919, Robinson, Mozell >
< 3, 920, Rodgers, Darryl >
11 rows found.

複製分散スキームの表でのreplicaSetId#の使用

この例では、最初にaccount_status表でttIsql describeコマンドを使用して、表が複製分散スキームであるかどうかを確認します。次に、replicasetId#を返す問合せを発行します。次に、別の接続から同じ問合せを繰り返します。この例は、返されるデータが、アプリケーションが接続されているレプリカ・セットに配置され、データベースのすべての要素に存在することを示しています(複製分散スキーム)。

Command> describe account_status;
 
Table SAMPLEUSER.ACCOUNT_STATUS:
  Columns:
   *STATUS                          NUMBER (2) NOT NULL
    DESCRIPTION                     VARCHAR2 (100) INLINE NOT NULL
 DUPLICATE
 
1 table found.
(primary key columns are indicated with *)

dual表を問い合せて、アプリケーションが接続されているレプリカ・セットを返します。この例では、レプリカ・セットは1です。

Command> SELECT replicaSetId# FROM dual; 
< 1 >
1 row found.

Command> SELECT replicaSetId#,* FROM account_status;
< 1, 10, Active - Account is in good standing >
< 1, 20, Pending - Payment is being processed >
< 1, 30, Grace - Automatic payment did not process successfully >
< 1, 40, Suspend - Account is in process of being disconnected >
< 1, 50, Disconnected - You can no longer make calls or receive calls >
5 rows found.

別のデータ・インスタンスで実行されている別のttIsqlセッションから2番目の問合せを発行します。

Command> SELECT elementid# from dual;
< 6>
1 row found.

Command> SELECT replicaSetId#, * FROM account_status;
< 3, 10, Active - Account is in good standing >
< 3, 20, Pending - Payment is being processed >
< 3, 30, Grace - Automatic payment did not process successfully >
< 3, 40, Suspend - Account is in process of being disconnected >
< 3, 50, Disconnected - You can no longer make calls or receive calls >
5 rows found.