[pgsql-jp: 27381] Re: 外部キーの設定確認方法

sugita @ sra.co.jp sugita @ sra.co.jp
2002年 9月 11日 (水) 16:28:44 JST


  杉田です。

From: Wataru Kojima <kojima @ ase.co.jp>
Date: Wed, 11 Sep 2002 14:06:17 +0900

;;; #もっといい方法がありそう。。。

  7.1.3/7.2 ではありませんが、次のリリースの 7.3 では、次のようにできます。

    =# \d sample
	Table "public.sample"
     Column |  Type   | Modifiers 
    --------+---------+-----------
     id     | integer | not null
     name   | text    | 
     u_id   | integer | 
    Foreign Key constraints: sample_foreign FOREIGN KEY (u_id) REFERENCES scott(id) ON UPDATE NO ACTION ON DELETE NO ACTION

    =# 

  psql -E でみると、次の関数が加わっています。

    ...
    ********* QUERY **********
    SELECT conname,
      pg_catalog.pg_get_constraintdef(oid) as condef
    FROM pg_catalog.pg_constraint r
    WHERE r.conrelid = '17001' AND r.contype = 'f'
    **************************

	Table "public.sample"
     Column |  Type   | Modifiers 
    --------+---------+-----------
     id     | integer | not null
     name   | text    | 
     u_id   | integer | 
    Foreign Key constraints: sample_foreign FOREIGN KEY (u_id) REFERENCES scott(id) ON UPDATE NO ACTION ON DELETE NO ACTION

    =# 


Kenji Sugita                                      





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