简体   繁体   中英

Is it a good solution to use temp table where there can be dependency involved among tables?

I need to insert values to one final summary table, from a lot of several different summary tables.

I first need to perform various summations on some of these small summary tables, on some I need to calculate averages, on some sum of averages. To achieve this, I created views (around 21 views) and then one view (that is union of select statements for joining 21 views). Then I created stored procedure to call this view and insert values to one final summary table. I able to achieve what I wanted but is this a clean solution? Can I create temp tables with/without using SP? Will dependency be impacted by having temp tables? I have dependency of views on each other, specially the final view which is union of all other views to calculate final summary of all tables.

I was able to work around this. Simply created SP, that creates temp tables. these temp tables contains select statements to calculate summation, average depending on what I wanted from each temp table. Then in same SP, I inserted data from these temp tables to summary table using insert query and doing UNION of all temp tables

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