惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Threatpost
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
The Blog of Author Tim Ferriss
S
SegmentFault 最新的问题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 司徒正美
T
Tailwind CSS Blog
The Cloudflare Blog
The Last Watchdog
The Last Watchdog
PCI Perspectives
PCI Perspectives
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
TaoSecurity Blog
TaoSecurity Blog
云风的 BLOG
云风的 BLOG
C
Cybersecurity and Infrastructure Security Agency CISA
O
OpenAI News
Recorded Future
Recorded Future
GbyAI
GbyAI
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Y
Y Combinator Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
量子位
博客园 - 叶小钗
V
Vulnerabilities – Threatpost
F
Full Disclosure
Recent Announcements
Recent Announcements
Vercel News
Vercel News
S
Schneier on Security
H
Heimdal Security Blog
Cisco Talos Blog
Cisco Talos Blog
V2EX - 技术
V2EX - 技术
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
B
Blog RSS Feed
宝玉的分享
宝玉的分享
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Privacy & Cybersecurity Law Blog
T
Threat Research - Cisco Blogs
G
Google Developers Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
爱范儿
爱范儿
IT之家
IT之家
大猫的无限游戏
大猫的无限游戏
C
Check Point Blog
N
Netflix TechBlog - Medium
S
Security @ Cisco Blogs
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Microsoft Azure Blog
Microsoft Azure Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Cyberwarzone
Cyberwarzone

博客园 - yier

ZZ:修改sharepoint文档库文件类型显示图标(PDF,WinRAR) ZZ: How to remove 'Open in Windows Explorer' from the 'Actions Menu' zz: 如何查询SQL Server数据库的版本 zz: 关闭WIN2003关机事件跟踪程序 zz:MOSS內容資料庫的分配與管理 zz:CAML簡介 zz:全局化定制MOSS樣式 zz:貼幾個常用的MOSS樣式選擇器 ZZ:SharePoint常用目录介绍 ZZ:如何修改默认的site template大小 ZZ:JMeter使用指南 ZZ: Moving or Renaming the WSS Central Administration Content Database Search settings - Authentication failed because the remote party has closed the transport stream - yier zz: Calculated Columns - Displaying Images from oscar zz:如何更改列表项前的New标记的天数设置(days-to-show-new-icon ) from Jianyi ZZ: Uploads with SharePoint 2007 - Antivirus From Eric Cherng zz: SharePoint 2007 Folders from Eric Cherng [原创] 在dos命令行里面取当天是“星期几" ZZ: 如何禁止掉SharePoint页面个性化?(续) from kaneboy
zz: 如何移動已存在的SQL Server 2005中的user database
yier · 2009-09-07 · via 博客园 - yier

如何移動已存在的SQL Server 2005中的user database

有時候主機的硬碟空間不足或是因為要調整硬碟配置, 會動到資料庫的存放位置, 這裡有一篇 kb 在處理這個作業.

移動使用者資料庫

內容說明蠻詳細的, 我這裡簡單列出操作的方式:

1. 先找出該 db 的所有檔案, 利用以下指令(其中USERDB是假設的使用者資料庫名稱):
SELECT name, physical_name AS CurrentLocation, state_desc
FROM sys.master_files
WHERE database_id = DB_ID(N'USERDB')

用戶插入圖片

(基本上至少會有兩個, 一個是放 data 的 mdf, 一個是放 log 的 ldf 檔案的所在位置)

2. 接下來將資料庫先離線:
ALTER DATABASE USERDB SET OFFLINE;
1).可能會花一些時間
2). USERDB 名称如若含有特别字符(空格,横线...) ,可以用“” 来包含.

3. 再來就是將資料庫的實體檔案搬移到指定位置, 這裡假設是 d:\sqldata\

4. 接下來就是將資料庫的 metadata 利用 alter database 指令進行調整:
ALTER DATABASE USERDB
    MODIFY FILE
 ( NAME = USERDB,
                  FILENAME = 'd:\sqldata\USERDB.mdf');
ALTER DATABASE USERDB
    MODIFY FILE
( NAME = USERDB_log,
                  FILENAME = 'd:\sqldata\USERDB_log.ldf');

5. 將資料庫上線:
ALTER DATABASE USERDB SET ONLINE;

6. 再次確認資料庫檔案所在位置:
SELECT name, physical_name AS CurrentLocation, state_desc
FROM sys.master_files
WHERE database_id = DB_ID(N'USERDB')

用戶插入圖片

7. 進行資料庫測試, 例如 select 一些資料, 確認沒問題後, 即完成.

這個作業其實偶而會用到, 而且機會不低, 尤其是檔案大小成長速度快的, 非常實用, 給大家參考, 另外這篇雖然是 SQL Server 2005 的資料, 不過 SQL Server 2000 也同樣適用. 當然, 使用 backup / restore 的方式也沒問題, 只是用這個方式會快得多了. 另外使用 detach / attach db 的方式也是一種做法(後面資料也有)

如何使用 SQL Server 中的卸離和附加功能將 SQL Server 資料庫移到新位置http://support.microsoft.com/kb/224071/zh-tw