

 O Amazon Redshift não permitirá mais a criação de UDFs do Python a partir do Patch 198. As UDFs do Python existentes continuarão a funcionar normalmente até 30 de junho de 2026. Para ter mais informações, consulte a [publicação de blog ](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>

Seleciona as linhas definidas por qualquer consulta e as introduz em uma nova tabela. Você pode especificar se deseja criar uma tabela temporário ou persistente. 

## Sintaxe
<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 ]
```

 Para obter detalhes sobre os parâmetros deste comando, consulte [SELECT](r_SELECT_synopsis.md). 

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

Selecione todas as linhas da tabela EVENT e crie uma tabela NEWEVENT: 

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

Selecione o resultado de uma consulta agregada em uma tabela temporária chamada 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;
```