23
17

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でselectした結果をinsertするSQL

Posted at

いつも忘れてしまうのでメモ。

PostgreSQLで、selectした結果をそのまま他テーブルにinsertする方法のSQL。
いつもの insert 文の後に select 文をくっつけるだけでいい。

というわけでSQLのサンプル。

insert into 宛先テーブル
(
	column1,
	column2,
	column3
)
select
	column1,
	column2,
	column3
from
	移行元テーブル
where
	column3 >= 100
23
17
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
23
17

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?