LoginSignup
0
0

More than 3 years have passed since last update.

PostgreSQL のwith と temporary table と view の差異を整理

Posted at

with と temporary table と viewの存在意義がごっちゃになったので簡単にまとめ

テーブルの実体を持つか否か

temporary tableは持つが、withとviewは持たない。
前者は物理的にテーブルを作成するので、disk書き込みなど生じる可能性はある。
後者はsqlに対するaliasみたいなものなので、実体持たない。呼び出される度に実行される。

スコープ

temprary tableは 同一セッションのみ
viewはdrop viewするまで
withは一つのクエリ内のみ

index

temporary table : 貼れる
view: 貼れない( MATERIALIZED VIEWというのを使えば貼れる)
with: 貼れない

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