【问题标题】:Create Table by Inserting Data from Select Statement created by With Statement通过从 With 语句创建的 Select 语句中插入数据来创建表
【发布时间】:2019-12-24 21:50:12
【问题描述】:

我有一个非常复杂的 with 语句,它结合了很多信息,可以在 teradata studio 中使用 select 语句来获取。 with 语句效果很好,可以选择我需要的数据,但我不知道如何从中创建视图,或将其保存为持久表,或对其进行任何操作以使其成为持久的选择方式数据。我想使用这个 with 语句将 select 语句保存为一个持久表,然后我可以在 ec2 实例中使用 tpt 脚本提取该表。

我曾经创建易失性表而不是使用 with 语句,并且我可以通过执行正确的选择和插入语句来创建表。但是,这将被放入生产环境并安排好,他们对此并不满意,并表示将其包装在 with 声明中。

我尝试将整个 with 语句包装到 create table 或 create view 语句中。我尝试更改获取数据的 select 语句并将其转换为 create table 或 insert into 语句,但这些似乎都不与 with 语句语法配合。

WITH
customer_month_ad AS
(

),

months_since_last_payment AS
(

),

customer_month_2 AS
(

),

customer_month AS
(

),

date_things AS
(

),


network AS
(

),

skeleton AS
(

),

customer_stuff AS
(

),

customer_keyz AS
(

),

customer_activity AS
(

),

order_date AS (

),

months AS
(

)--,

SELECT *
FROM customer_month_ad
;

我想将 select 语句的输出保存到一个持久表中。

【问题讨论】:

标签: sql teradata create-table with-statement


【解决方案1】:

试试这个查询

create table <your_table_name> as select * from <table_names>

create table <your_table_name> as <your_select_statement>

替换:

<your_table_name> 通过结果表的名称

<table_names> 来自数据来源的表的名称

<your_select_statement> 如果你有一个不同的语句,则选择语句

不像select * from .......

【讨论】:

  • 谢谢,这正是我想做的。我现在有一个假脱机空间错误,但我可以解决这个问题。 create table table1 as (with statement select statement) with data ;
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-09-05
  • 2013-06-23
  • 2016-02-25
  • 2021-01-28
  • 2013-12-25
  • 1970-01-01
  • 2014-01-20
相关资源
最近更新 更多