SQL Server从100多个表中选择数据 [英] SQL Server select data from 100+ tables

查看:43
本文介绍了SQL Server从100多个表中选择数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据库,其中包含100多个表,其中包含来自传感器的数据;每个传感器一张桌子.并且使用100多个 union all 并不是很好.因此,有没有更好的方法可以从所有表格中以最大的利润来收集数据?

I have a database which contains 100+ tables with data from sensors; one table for each sensor. And using 100+ union all is not good. So, is there a better way to collect data from all tables with maximum profit?

推荐答案

正如其他评论者所指出的,全部联合(可选地打包到视图中)是这里的唯一解决方案.

As other commenters have pointed out, union all (optionally packed into a view) is the only solution here.

但是,最好让自己熟悉 SQL Server对具有大量代码的查询施加的某些警告和限制>联合语句.幸运的是,您的公司最终可能会达到这些限制之一,这可能迫使管理层重新考虑数据库设计方法.

However, it is better to acquaint yourself with certain caveats and limitations that SQL Server imposes on queries with numerous union statements. With luck, your company might eventually hit one of those limits, which might force the management to reconsider the approach to the database design.

这篇关于SQL Server从100多个表中选择数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆