简体   繁体   English

“单元”测试数据库

[英]“Unit” Testing Database

I'm running Oracle 11g SE1 . 我正在运行Oracle 11g SE1。

Just wondering if there're any tools that would allow me to test the data integrity of a ( mostly read-only ) schema. 只是想知道是否有任何工具可以让我测试(主要是只读的)模式的数据完整性。 Essentially, what I want to do is to have some queries that run every night or so and see if they return the expected result. 本质上,我想做的是让一些查询每天晚上左右运行,并查看它们是否返回预期的结果。 For example: 例如:

SELECT COUNT(*) FROM PATIENTS WHERE DISEASE = 'Clone-Killing Nanovirus'; 
Expected result : 59. 

How do people normally do such testing ? 人们通常如何进行此类测试?

I've used SQLUnit and written about it here . 我用过SQLUnit在这里写过。 I don't believe any new development is being done on it but it should accomplish your goal. 我不认为正在对此进行任何新的开发,但是它应该可以实现您的目标。

SQL Developer (free, as in beer) also has a Unit Testing framework. SQL Developer (像啤酒一样免费)还具有单元测试框架。 I have installed it and that's about it. 我已经安装了它,仅此而已。 I want to use it more, but I've been working with BI the past few years so no external pressure to learn it. 我想更多地使用它,但是过去几年我一直在与BI合作,因此没有外部压力来学习它。

The tests that you want to create sound pretty simple, so either of those should work well for you. 您想要创建的测试听起来很简单,所以其中任何一个都应该对您有效。 The next step would be to have them run on a schedule (cron, windows scheduler, etc) or you can go crazy with a continuous integration tool like Atlassian's Bamboo (haven't used it). 下一步是让它们按计划运行(cron,Windows计划程序等),或者您可以像Atlassian的Bamboo那样的持续集成工具发疯(尚未使用过)。

Of course you could skip the tools altogether and just write up scripts that are called from the command line. 当然,您可以完全跳过这些工具,而只需编写从命令行调用的脚本。 Fancy would have you writing the results to a database table so you can easily skin it, simple would be piping the results to a text file and reviewing that each day. 花哨的是,您需要将结果写入数据库表,以便您可以轻松对其进行外观设计,只需将结果通过管道传输到文本文件中,然后每天进行审查。

Hope this helps. 希望这可以帮助。

You could batch up your queries and run a simple perl script using DBI that would run the queries and check them against an accepted tolerance and email you if something didn't meet thresholds. 您可以批处理查询并使用DBI运行简单的perl脚本,该脚本将运行查询并根据可接受的公差检查它们,并在不符合阈值的情况下向您发送电子邮件。 I know I have written such db checking code before to make sure items were within thresholds. 我知道我已经写过这样的数据库检查代码,以确保项目在阈值之内。 Perl is a good tool for this sort of thing as the DBI module can connect to your database and then you can run some canned queries and easily send yourself an email using the MIME package. Perl是解决这类问题的好工具,因为DBI模块可以连接到数据库,然后您可以运行一些固定查询,并可以使用MIME包轻松地向自己发送电子邮件。 http://www.perl.com/pub/1999/10/DBI.html http://www.perl.com/pub/199​​9/10/DBI.html

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

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