[pgsql-jp: 31046] common sence?

Toshio Uchiyama uchiyama @ shonan.homeunix.org
2003年 9月 14日 (日) 05:45:07 JST


お世話になります.内山と申します.宜しくお願いします.

ちょっと,愚痴になるのですが,以上の2項目って常識ではありませんか?

create tabel t1 ( f1 char(10), f2 char(10) );

としてテーブルを作り,

 f1 | f2
----+----
  1 |  1
  2 |  2
(2 rows)

のようにデータを入れてやる.そして

select distinct * from t1 where f1 is not null and f1 = '1' order by f1;

とやると

 f1 | f2
----+----
  1 |  1

(1 rows)

のように,f1 と f2 の列の並び順は,create 文で作った順序になる(常識1).
加えて,PostgreSQL では,できないようですが,

select distinct * from t1 where f1 is not null and f1 = '1' order by f1 union\
select distinct * from t1 where f1 is not null adn f1 = '2' order by f1;

とやって

select distinct * from t1 where f1 is not null and f1 = '1' order by f1

でできる中間仮想テーブルと

select distinct * from t1 where f1 is not null and f1 = '2' order by f1

でできる中間仮想テーブルを union してやると,

 f1 | f2
----+----
  1 |  1
  2 |  2
(2 rows)

のように,行

 1 | 1

と行

 2 | 2

のレコード順は保持される(常識2).

私が常識と考える1と2は,本当は保証されないものなのでしょうか?
某M$社製の personal use 向けデータベースエンジンでは,これらの
常識が通用しません.これで,私は,ミスをしてしまい折角の休日
も休みは休みなのですが,休み開けに復旧させなければならず,
気持ちは休めないです.



pgsql-jp メーリングリストの案内