1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【MEMO】Postgresでtable/viewの列定義を取得する

Posted at

Postgresでtable/viewの列定義を取得する

キャッシュしといて、定義変わったらときに再取得した良さげ。


SELECT
  t0.table_catalog,
  t0.table_type,
  t0.table_schema,
  t0.table_name,
  t1.column_name,
  t1.data_type,
  t1.is_nullable
FROM information_schema.tables t0
INNER JOIN information_schema.columns t1
  ON t0.table_schema = t1.table_schema
    AND t0.table_name = t1.table_name
WHERE t0.table_schema <> 'information_schema'
  AND t0.table_schema <> 'pg_catalog';

目指せ、なんちゃって汎用テーブル。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?