admin管理员组文章数量:1122846
Is there any way to create a temporary table in Google Cloud Spanner through:
SELECT * INTO <temp table> FROM <table name>
where I can then use the temp table with multiple other queries in the same batch?
Is there any way to create a temporary table in Google Cloud Spanner through:
SELECT * INTO <temp table> FROM <table name>
where I can then use the temp table with multiple other queries in the same batch?
Share Improve this question asked yesterday Raj ChaudharyRaj Chaudhary 1,7523 gold badges22 silver badges34 bronze badges1 Answer
Reset to default 1That is not directly supported in the way that you describe. There are a couple of alternatives:
- Create a normal table and fill it with the data:
CREATE TABLE temp_table (id int64, value string(max)) primary key (id);
INSERT INTO temp_table (id, value) SELECT * FROM table_name;
Note that the insert statement is limited by the mutation limit in Spanner: https://cloud.google.com/spanner/quotas#limits-for (Mutations per commit)
- Use a common table expression:
WITH temp_table AS (
SELECT *
FROM table_name
)
SELECT col1, col2
FROM temp_table
One limitation of common table expressions, is that they are only visible to the query they are defined. It is not possible to re-use the same common table expression in multiple queries, other than by repeating the definition in the query.
https://cloud.google.com/spanner/docs/reference/standard-sql/query-syntax#with_clause
本文标签: google cloud platformHow to create temporary tables in SpannerStack Overflow
版权声明:本文标题:google cloud platform - How to create temporary tables in Spanner - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736283144a1926870.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论