

 Amazon Redshift は、パッチ 198 以降、新しい Python UDF の作成をサポートしなくなります。既存の Python UDF は、2026 年 6 月 30 日まで引き続き機能します。詳細については、[ブログ記事](https://aws.amazon.com/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/)を参照してください。

# SELECT INTO
<a name="r_SELECT_INTO"></a>

任意のクエリによって定義された行を選択して、新しいテーブルに挿入します。一時テーブルと永続的テーブルのどちらを作成するかを指定できます。

## 構文
<a name="r_SELECT_INTO-synopsis"></a>

```
[ WITH with_subquery [, ...] ]
SELECT
[ TOP number | [ ALL | DISTINCT ]
* | expression [ AS output_name ] [, ...] ]
[ EXCLUDE column_list ]
INTO [ TEMPORARY | TEMP ] [ TABLE ] new_table
[ FROM table_reference [, ...] ]
[ WHERE condition ]
[ [ START WITH expression ] CONNECT BY expression ]
[ GROUP BY ALL | expression [, ...] ]
[ HAVING condition ]
[ QUALIFY condition ]
[ { UNION | ALL | INTERSECT | EXCEPT | MINUS } query ]
[ ORDER BY expression [ ASC | DESC ] ]
[ LIMIT { number | ALL } ]
[ OFFSET start ]
```

 このコマンドのパラメータに関する詳細については、「[SELECT](r_SELECT_synopsis.md)」を参照してください。

## 例
<a name="r_SELECT_INTO-examples"></a>

EVENT テーブルからのすべての行を選択し、NEWEVENT テーブルを作成します。

```
select * into newevent from event;
```

集計クエリの結果を選択して、PROFITS という名前の一時テーブルに格納します。

```
select username, lastname, sum(pricepaid-commission) as profit
into temp table profits
from sales, users
where sales.sellerid=users.userid
group by 1, 2
order by 3 desc;
```