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?

スキーマの名前を調べる

sch で始まるスキーマ

SELECT schema_name FROM information_schema.schemata where schema_name LIKE 'sch%';

テーブルの名前を調べる

grp で始まるテーブル

select table_name from information_schema.tables where table_name LIKE 'grp%';

grp で始まるテーブルの数

select count(*) from information_schema.tables where table_name LIKE 'grp%';

コラムの名前を調べる

SELECT column_name FROM information_schema.columns WHERE table_name = 'cities';

実行結果

city=# SELECT column_name FROM information_schema.columns WHERE table_name = 'cities';
 column_name 
-------------
 population
 date_mod
 id
 name
(4 rows)

コラムの名前 と Not Null かを調べる

SELECT column_name, is_nullable FROM information_schema.columns WHERE table_name = 'cities';

実行結果

city=# SELECT column_name, is_nullable FROM information_schema.columns WHERE table_name = 'cities';
 column_name | is_nullable 
-------------+-------------
 population  | YES
 date_mod    | YES
 id          | NO
 name        | YES
(4 rows)

コラム名を与えてテーブル名を調べる

select table_name from information_schema.columns WHERE column_name = 'population';
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?