SQLSERVER AUTO_CLOSE选项

SQLSERVER AUTO_CLOSE选项

sql2000技术内幕

AUTO_CLOSE

When this option is set to ON (the default when SQL Server runs on Windows 98), the database is closed and shut down cleanly when the last user of the database exits, thereby freeing any resources. When a user tries to use the database again, it automatically reopens. If the database was shut down cleanly, the database isn't initialized (reopened) until a user tries to use the database the next time SQL Server is restarted. The AUTO_CLOSE option is handy for personal SQL Server databases because it allows you to manage database files as normal files. You can move them, copy them to make backups, or even e-mail them to other users. However, you shouldn't use this option for databases accessed by an application that repeatedly makes and breaks connections to SQL Server. The overhead of closing and reopening the database between each connection will hurt performance.

默认是关闭的

当auto_close选项设置为ON的时候,当最后一个用户退出数据库的时候,数据库就会clean shutdown并关闭,因而释放资源

当一个用户再次尝试使用数据库的时候,数据库会自动重新打开。

如果数据库是clean shutdown的,那么数据库在重新打开的时候reopen不需要重新初始化直到一个用户在下次sqlserver重启的时候尝试使用数据库

auto_close只为sqlserver个人版准备,因为这允许你作为正常文件去管理数据库文件

你能移动数据文件在关闭SQL Server的情况下,使用复制数据文件的方法去备份数据库,或者甚至发电邮去通知其他用户

然而,你的程序重复建立连接和打断连接而使用auto_close选项。关闭和重开数据库连接会造成性能上的下降

 

posted @ 2014-08-19 09:22  桦仔  阅读(1624)  评论(0编辑  收藏  举报