SQL Server 使用Detach和Attach 方式 移动数据库位置
来源:互联网 发布:node*next 编辑:程序博客网 时间:2024/05/18 00:52
数据库备份和权限等云云的概念就不介绍了, 直接进入主题操作了
环境:
1. 服务器 SQL Server 2005
2. 客户端工具: SQL Server Management Studio
3. 需要移动的数据库名是: oscardb
步骤
1. 查看并记录当前数据库的数据文件和日志文件的名称以及位置。
方式有两种:
- 界面直接操作, 选中需要移动的数据库, 右键点击选”属性“, 在“文件”选择页就能看到。
- 在SQL Server Management Studio 点击“新建查询", 进入SQL查询,输入
use oscardbgo sp_helpfilego
2. 以独占方式访问数据库, 防止有其他人在使用
use mastergoalter database oscardbset single_usergo
3. 分离数据库
也是两种方式:
界面操作, 右键点击数据库-> 任务--> 分离
SQL语句
use mastergo sp_detach_db 'oscardb'go
4. 将数据和日志文件移动到新位置(我这边是 D:\sqlserverdata)
5. 附件指定文件的数据库
页面操作在数据库上右键 -- attach.
SQL语句是:
use mastergo sp_attach_db 'xuemingdb','D:\sqlserverdata\oscardb.mdf','D:\sqlserverdata\oscardb_log.ldf'go
- SQL Server 使用Detach和Attach 方式 移动数据库位置
- 如何通过使用 SQL Server 中的 Detach 和 Attach 函数将 SQL Server 数据库和日志文件移到新位置
- 如何通过使用 SQL Server 中的 Detach 和 Attach 函数将 SQL Server 数据库移到新位置(转载)
- 如何通过使用 SQL Server 中的 Detach 和 Attach 函数将 SQL Server 数据库移到新位置
- 如何通过使用 SQL Server 中的 Detach 和 Attach 函数将 SQL Server 数据库移到新位置
- 使用C# Detach和Attach 数据库
- attach和detach
- Attach、Detach和DeleteObject
- attach和detach
- Attach、Detach和DeleteObject
- Attach、Detach和DeleteObject
- Attach、Detach和DeleteObject
- Attach、Detach和DeleteObject
- attach和detach区别
- Attach()函数和Detach()函数
- GetOwner和Getparent,Attach和Detach
- 关于attach和detach的疑问
- MFC Attach()函数和Detach()函数
- Factorization
- oracle等待事件1——高速缓冲内cbc latch
- 七宗罪----人性本恶
- javascript的动态this与动态绑定
- [转]JAVA格式化时间日期
- SQL Server 使用Detach和Attach 方式 移动数据库位置
- 雁过也,月满西楼
- 面向对象之依赖、关联、聚合、组合
- 浮华落寂
- 编译help工具
- apk之间资源共享
- RTSP会话
- _cdecl
- lights从上到下的流程