9月 04

select coalesce(カラム名, ‘0′);

指定したカラムがNULLだったら「0」が返って来る。

select coalesce(カラム名その1, カラムその2名,’0′);

「カラム名その1」がNULLだったら「カラムその2」の値を使う。「カラムその2」がNULLだったら「0」を返す。

「ISNULL」はポスグレにはないらしい。

Tagged with:
6月 19

SELECT EXTRACT(YEARS FROM AGE(TO_DATE(文字列格納カラム,’YYYYMMDD’))) AS USER_AGE FROM テーブル名;

Tagged with:
6月 14

select attname from pg_attribute where attrelid = (select oid from pg_class where relname = ‘テーブル名’) and attnum > 0 and atttypid > 0;

Tagged with:
3月 24

SELECT * FROM PG_TABLES;

もちろんWHERE条件を加えて絞り込むことも可能。まずは一覧を表示してみればどういう情報が出力されるのかわかる。

\d

でも十分なんですけどね。

Tagged with:
Get Adobe Flash playerPlugin by wpburn.com wordpress themes
preload preload preload