问题
what are the main purposes for which temporary tables are used? I want to know the practical and commercial uses of temporary tables in actual softwares working in small and large scale companies.
回答1:
In my experience, temporary tables are often used to store intermediate calculations in a complex series of CREATE or UPDATE queries that produce some sort of analysis result. An example might be the creation of summary tables for an OLAP database.
Temporary tables are also sometimes used to increase performance, in certain situations.
回答2:
I tend to prefer using CTEs (common table expressions) to temporary tables. There is a good discussion in answer to a similar question.
来源:https://stackoverflow.com/questions/4976585/what-are-the-use-cases-for-temporary-tables-in-sql-database-systems