定期重置嵌入式H2数据库 [英] Reset Embedded H2 database periodically
本文介绍了定期重置嵌入式H2数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在演示服务器中设置我的应用程序的新版本,很想找到一种每天重置数据库的方法.我想我总是可以通过cron作业来执行drop和创建查询,但是我正在寻找一种更清洁的方法.我尝试使用带有拖放创建方法的特殊持久性单元,但由于系统频繁(按需)与服务器连接和断开连接,因此该单元不起作用.
I'm setting up a new version of my application in a demo server and would love to find a way of resetting the database daily. I guess I can always have a cron job executing drop and create queries but I'm looking for a cleaner approach. I tried using a special persistence unit with drop-create approach but it doesn't work as the system connects and disconnects from the server frequently (on demand).
有更好的方法吗?
推荐答案
H2支持对删除所有对象:
DROP ALL OBJECTS [DELETE FILES]
如果您不想删除所有表,则可能要使用截断表:
If you don't want to drop all tables, you might want to use truncate table:
TRUNCATE TABLE
这篇关于定期重置嵌入式H2数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文