选择进入PostgreSQL中的临时表? [英] Select into temp table in PostgreSQL?

查看:99
本文介绍了选择进入PostgreSQL中的临时表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在PostgreSQL中使用select into创建临时表。例如,在SQL 中,从source_tab选择*到temp_tab;

How to create temporary table using select into in PostgreSQL. For example in SQL Select * into temp_tab from source_tab;

推荐答案

您可以尝试使用 创建表为 命令,如下所示:

You can try to use Create Table As command like this:

CREATE TEMP TABLE mytable AS
SELECT * from source_tab;

来自文档:


此命令在功能上与SELECT INTO 类似,但是它是首选命令,因为它不太可能与
SELECT INTO语法的其他用法混淆。此外,CREATE TABLE AS提供了SELECT INTO提供的功能的超集

This command is functionally similar to SELECT INTO, but it is preferred since it is less likely to be confused with other uses of the SELECT INTO syntax. Furthermore, CREATE TABLE AS offers a superset of the functionality offered by SELECT INTO.

CREATE TABLE AS命令允许用户显式指定
是否应包含OID。如果未明确指定OID的存在
,则将使用default_with_oids配置变量

The CREATE TABLE AS command allows the user to explicitly specify whether OIDs should be included. If the presence of OIDs is not explicitly specified, the default_with_oids configuration variable is used.

这篇关于选择进入PostgreSQL中的临时表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆