ハセテツラボ

生涯一開発屋

Archive for 6月, 2006

‘YYYYMMDD’形式の文字列から年齢を取得する

without comments

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

Written by

6月 19th, 2006 at 3:37 pm

Posted in PostgreSQL

Tagged with

指定したテーブルのカラム一覧の取得

without comments

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

Written by

6月 14th, 2006 at 6:59 pm

Posted in PostgreSQL

Tagged with