0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PostgreSQLにてテーブルの所有者と各カラムの情報を取得するSQL

Posted at

テーブル情報

SELECT
  PG_TABLES.schemaname AS "スキーマ名",
  PG_TABLES.tablename AS "テーブル名",
  PG_TABLES.tableowner AS "所有者"
FROM
  PG_TABLES

カラム情報

SELECT
  COLUMNS.table_catalog AS データベース名,
  COLUMNS.table_schema AS スキーマ名,
  COLUMNS.table_name AS テーブル名,
  COLUMNS.column_name AS カラム名,
  COLUMNS.ordinal_position AS 列番号,
  COLUMNS.column_default AS 初期値,
  COLUMNS.is_nullable AS NULL許容,
  COLUMNS.data_type AS データ型,
  COLUMNS.character_maximum_length AS 最大文字数,
  COLUMNS.character_octet_length AS 最大バイト数,
  COLUMNS.numeric_precision AS 最大桁数
FROM
  INFORMATION_SCHEMA.COLUMNS
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?