列ファミリーがあるとします
CREATE TABLE cnt_test (time_slot text , comp1 text, comp2 text, field1 counter, field2 counter, PRIMARY KEY(time_slot,comp1, comp2));
今、私はそれにいくつかのデータを挿入しようとしています
UPDATE cnt_test SET field1=field1+1, field2=field2+2 WHERE time_slot='20130924' AND comp1='' AND comp2='ABC';
UPDATE cnt_test SET field1=field1+1, field2=field2+2 WHERE time_slot='20130924' AND comp1='' AND comp2='ABC';
UPDATE cnt_test SET field1=field1+1, field2=field2+2 WHERE time_slot='20130924' AND comp1='' AND comp2='ABC';
UPDATE cnt_test SET field1=field1+1, field2=field2+2 WHERE time_slot='20130924' AND comp1='' AND comp2='XYZ';
UPDATE cnt_test SET field1=field1+1, field2=field2+2 WHERE time_slot='20130924' AND comp1='PQR' AND comp2='';
上記のステートメントでわかるように、複合キー部分にいくつかの空の値を挿入しました。null の代わりに空白文字を入れています。
同じクエリを実行することもできます
SELECT * FROM cnt_test WHERE time_slot='20130924' AND comp1='' AND comp2='ABC';
time_slot | comp1 | comp2 | field1 | field2
-----------+-------+-------+--------+--------
20130924 | | ABC | 4 | 8
(1 rows)
SELECT * FROM cnt_test WHERE time_slot='20130924' AND comp1='PQR' AND comp2='';
time_slot | comp1 | comp2 | field1 | field2
-----------+-------+-------+--------+--------
20130924 | PQR | | 1 | 2
(1 rows)
したがって、すべてを要約するには、null 列の値を空の列に置き換えるだけです。''