简体   繁体   中英

Difference between WITH and INTO for temporary table creation

WITH and INTO seem very similar. Both create temporary tables. What differentiates them?

WITH doesn't create a temporary table. It allows you assign names to subqueries and then reference them in your actual query as if they were tables or views. It allows you to do stepwise-refinement on a query in a way that would otherwise require either a series of defined table variables/temp tables, or a horrific tangle of nested subqueries.

One way to think of it is as a way of pre-defining your subqueries and then referencing them by name rather than putting the query expression in your final query.

SELECT INTO , on the other hand, just creates a table based on the results of the SELECT .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM