简体   繁体   English

如何检查sql查询是否是确定性的?

[英]How can I check if a sql query is deterministic?

What I mean by deterministic is that the query will always return exactly the same result set. 我所说的确定性是查询将始终返回完全相同的结果集。 Is there a way to do this? 有没有办法做到这一点?

Queries aren't typically considered to be deterministic as the underlying tables can change between invocations. 通常不认为查询是确定性的,因为基础表可以在调用之间进行更改。 Determinism typically only comes into play when talking about UDFs. 确定性通常仅在谈论UDF时起作用。

The only way I know of to produce deterministic data in a database is to create a snapshot of the necessary data at the appropriate point in time. 我知道在数据库中生成确定性数据的唯一方法是在适当的时间点创建必要数据的快照。 Usually, data is transformed and loaded into a data warehouse, along with a timestamp for the rows being archived, for later retrieval. 通常,数据会被转换并加载到数据仓库中,并附带要归档的行的时间戳,以供以后检索。 Auditing and other kinds of reporting queries may be run against the data warehouse, and the results are "deterministic" for any given time period, but not across time periods. 可以针对数据仓库运行审核和其他类型的报告查询,并且结果在任何给定时间段内都是“确定性的”,但不能跨时间段。

Information housed in a data warehouse may also be precomputed into a multi-dimensional cube for faster processing, if necessary. 如有必要,还可以将数据仓库中存储的信息预先计算为多维多维数据集以进行更快的处理。 To maintain proper form, data warehouse tables should only ever be inserted into, and new batches of data should always be associated with a unique timestamp. 为了保持适当的格式,应该只将数据仓库表插入其中,并且新一批数据应始终与唯一的时间戳关联。 It is usually best to store data in some form of star or snowflake schema , which facilitates generation of a cube if necessary. 通常最好以星形或雪花模式的某种形式存储数据,如果需要的话,这可以简化多维数据集的生成。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何有效检查SQL查询中是否存在记录? - How can I efficiently check if records exists with sql query? 如何检查SQL查询是否没有结果? - How can I check that a SQL query has no result? 如果我在没有ORDER BY的情况下对SQL SELECT查询进行分区,结果是否具有确定性? - Are the results deterministic, if I partition SQL SELECT query without ORDER BY? 如何在SQL查询中检查子字符串? - How do I check the substring in a query in SQL? 为什么这个 SQL Function TicksToDateTime 是不确定的? 以及如何使其具有确定性? - Why is this SQL Function TicksToDateTime non-deterministic? and how to make it deterministic? 如何检查具有给定正则表达式格式的sql查询中的用户输入格式? - How can i check for a format of user input in sql query with a given regex format? 如何编写SQL查询来检查数据库中是否存在特定的表? - How can I write a sql query to check if a particular table exists in a database? 如何在不运行实际查询的情况下检查JDBC语句的SQL语法? - How can I check SQL syntax for a JDBC statement without running the actual query? 如果查询返回空行,我需要将其获取为零值,如何在Sql中对其进行检查? - If a query return empty row i need to get its as zero value,How can check it in Sql? 如何在SQL查询中的where条件中放置where条件以检查数量 - how can i put where condition in where condition in SQL Query to check qty
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM