描述
Detaches a SQL Server Express geodatabase (.mdf).
Removes all references to the geodatabase from the database server. It does not delete the data file (.mdf). Once detached, you can attach the data file to another SQL Server Express instance.
使用方法
The .mdf file and the full-text catalog for the database are in the directory in which you initially created the geodatabase.
When copying a detached geodatabase to another server, you do not need to copy the .ldf file. The Attach Database tool creates a new .ldf. You must copy the full-text catalog with the database (.mdf). For SQL Server 2008 Express, the full-text catalog is in the .mdf file. For the full-text catalog to transfer properly, the database server to which you move the geodatabase must also be set up to use SQL Server Full-Text Search.
The geodatabase must not be in use by another process during detach.
You must have Server Administrator privileges to detach a geodatabase.
语法
arcpy.production.DetachDatabase(workspace)
参数 | 说明 | 数据类型 |
workspace | The geodatabase to detach from an instance of SQL Server Express. | Workspace |
代码示例
DetachDatabase example (stand-alone script)
The following stand-alone script demonstrates how to use the DetachDatabase tool.
# Name: DetachDatabase_Example.py
# Description: Detaches a geodatabase (.mdf file) from an instance of SQL Server Express
# Requirements: Production Mapping extension
# import arcpy and checkout a Production Mapping license
import arcpy
arcpy.CheckOutExtension("foundation")
# local variable for the workspace parameter
gds_workspace = "Database Servers\\YOURSERVER_SQLEXPRESS.gds\\ProductLibrary (VERSION:DBO.DEFAULT)"
# detach the geodatabase from the SQL Server Express instance
arcpy.DetachDatabase_production(gds_workspace)
print "Script completed successfully."
# Check in the extension
arcpy.CheckInExtension("foundation")
环境
许可信息
- Basic: 否
- Standard: 需要 Production Mapping
- Advanced: 需要 Production Mapping