SQL SAP HANA 从选择创建表/插入新表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39616015/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SAP HANA create table / insert into new table from select
提问by Thorsten Niehues
How to create a new table and insert content of another table?
如何创建一个新表并插入另一个表的内容?
回答by Thorsten Niehues
create column table my_new_table as
(select * from my_existing_table)
回答by Lars Br.
Another, more SAP HANA specific solution is to use the
另一个更特定于 SAP HANA 的解决方案是使用
CREATE TABLE ... LIKE <TABLE_NAME> WITH [NO] DATA ...
This allows more control over the physical properties of the new table.
这允许对新表的物理属性进行更多控制。
回答by Wellington Gasparin
Like SQL Server you can create a temp table right from your select, the way is a little bit different.
像 SQL Server 一样,您可以直接从您的选择中创建一个临时表,但方式略有不同。
Just execute:
只需执行:
temp_table = select 1 as col1, 'lorem ipsum' as col2 from dummy;
After that, you are able to use this temp table to query data from.
之后,您就可以使用这个临时表来查询数据。
Like so:
像这样:
select * from :temp_table;
Table Variable Type Definition
Unfortunately, there is some limitations using that. For example, you cannot simply insert new data. For that, exists some tricks.
不幸的是,使用它有一些限制。例如,您不能简单地插入新数据。为此,存在一些技巧。