使用其他表格中的选择创建外部表格 [英] Create external table with select from other table
问题描述
我正在使用HDInsight,并且在完成运行查询时需要删除我的群集。但是,我需要收集的数据才能在一天之后生存下来。我正在处理将从table1创建计算列并将它们插入到table2中的查询。首先,我想要一个简单的测试来复制行。你能从select语句创建一个外部表吗?
I am using HDInsight and need to delete my clusters when I am finished running queries. However, I need the data I gather to survive for another day. I am working on queries that would create calculated columns from table1 and insert them into table2. First I wanted a simple test to copy the rows. Can you create an external table from a select statement?
drop table if exists table2;
create external table table2 as
select *
from table1
STORED AS TEXTFILE LOCATION 'wasb://{container name}@{storage name}.blob.core.windows.net/';
推荐答案
是的,但您必须将其分为两个命令。首先创建外部表然后填充它。
$ b
yes but you have to seperate it into two commands. First create the external table then fill it.
create external table table2(attribute STRING)
STORED AS TEXTFILE
LOCATION 'table2';
INSERT OVERWRITE TABLE table2 Select * from table1;
table2的模式必须与select查询相同,在本例中它只包含一个字符串属性。
The schema of table2 has to be the same as the select query, in this example it consists only of one string attribute.
这篇关于使用其他表格中的选择创建外部表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!