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?

More than 5 years have passed since last update.

PostgreSQLの便利なSQL達

Last updated at Posted at 2020-04-08

PostgreSQLの便利なSQL達

目的

自分メモと新卒応援でもあります。
追加予定あり。
追加してほしいものがあれば、コメントによろしくお願いいたします。

テーブル情報の取得

SELECT 
        * 
FROM 
        information_schema.columns 
WHERE 
        table_name = 'テーブル名' 
ORDER BY 
        ordinal_position;

View定義の取得

 SELECT definition FROM pg_views WHERE viewname = 'View名';

Viewとは以下を参照ください。
https://wa3.i-3-i.info/word17908.html

全View名の取得

SELECT viewname, definition FROM pg_views ;

カラム検索

select table_name, column_name from information_schema.columns where column_name ='検索するカラム名';

他方にないレコード検索

select * from 売上 left outer join 顧客 on (売上.顧客CD = 顧客.顧客CD)
where 顧客.顧客CD is null
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?