国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > 綜合 > 正文

移動(dòng)數(shù)據(jù)庫

2024-07-21 02:13:04
字體:
供稿:網(wǎng)友
  在sql server 中可以使用拆分(detach)和附加(attach)的方法來移動(dòng)數(shù)據(jù)庫。拆分?jǐn)?shù)據(jù)庫是從服務(wù)器中移去邏輯數(shù)據(jù)庫,但不會(huì)將操作系統(tǒng)中的數(shù)據(jù)庫文件刪除。附加數(shù)據(jù)庫將會(huì)創(chuàng)建一個(gè)新的數(shù)據(jù)庫,并復(fù)制存儲(chǔ)在已有的數(shù)據(jù)庫文件和事務(wù)日志文件中的數(shù)據(jù)。使用系統(tǒng)存儲(chǔ)過程sp_detach_db 來拆分?jǐn)?shù)據(jù)庫,用系統(tǒng)存儲(chǔ)過程sp_attach_db 來附加數(shù)據(jù)庫。

sp_detach_db 系統(tǒng)存儲(chǔ)過程的語法如下:
sp_detach_db [@dbname =] 'database_name'
[, [@skipchecks =] 'skipchecks']
其中[@skipchecks =] 'skipchecks'子句中skipchecks 的值為true 或false。 當(dāng)skipchecks的值為true 時(shí),指定在執(zhí)行此過程之前不需要對數(shù)據(jù)庫中的所有表執(zhí)行update statistics命令;為false 時(shí),則需要執(zhí)行update statistics 命令。

sp_attach_db 系統(tǒng)存儲(chǔ)過程的語法如下:
sp_attach_db [@dbname =] 'dbname',
[@filename1 =] 'filename_n' [,...16]
其中“filename_n”包括文件的路徑和物理名稱。最多可指定16 個(gè)文件。文件中必須包含主數(shù)據(jù)庫文件。如果需要附加的文件超過了16 個(gè),就必須使用帶for attach 子句的create database 命令來代替。
注意:sp_attach_db系統(tǒng)存儲(chǔ)過程中只能作用于那些已經(jīng)用sp_detach_db系統(tǒng)存儲(chǔ)過程從服務(wù)器中拆分出來的數(shù)據(jù)庫。

例6-16:移動(dòng)數(shù)據(jù)庫mytest 到e:/sql data 目錄下。
(1) 在sql server query analyzer 中運(yùn)行系統(tǒng)存儲(chǔ)過程sp_helpdb, 得到mytest數(shù)據(jù)庫所包含的文件名稱、數(shù)量、類型、存放位置等信息。命令語句如下:
exec sp_helpdb mytest



(2) 在sql server query analyzer 中運(yùn)行sp_detach_db 系統(tǒng)存儲(chǔ)過程,拆分mytest數(shù)據(jù)庫。命令語句如下:
exec sp_detach_db mytest, true

運(yùn)行結(jié)果如下:
successfully detached database 'mytest1'.
dbcc execution completed. if dbcc printed error messages, contact your system administrator.

(3) 在操作系統(tǒng)的文件夾窗口中用剪切或粘貼的方式直接將與數(shù)據(jù)庫相關(guān)的操作系統(tǒng)文件移動(dòng)到e:/ sql data 2000 server 目錄下。即將d:/sql data/mytest_data.mdf 文件和d:/sqldata/mytest_log.ldf 文件移到e:/ sql data 2000

(4) 在sql server query analyzer 中運(yùn)行sp_attach_db 系統(tǒng)存儲(chǔ)過程,附加文件到mytest 數(shù)據(jù)庫。命令語句如下:
exec sp_attach_db @dbname = 'mytest',
@filename1 = 'e:/sql data/mytest_data.mdf',
@filename2 = 'e:/sql data/mytest_log.ldf'

運(yùn)行結(jié)果如下:
successfully attached database 'mytest'.
至此已完成了數(shù)據(jù)庫的移動(dòng)工作,可在enterprise manager 中查看mytest 數(shù)據(jù)庫的信息,也可以在sql server query analyzer 中運(yùn)行系統(tǒng)存儲(chǔ)過程sp_helpdb 來查看移動(dòng)是否成功。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 龙南县| 长丰县| 石首市| 荥经县| 余江县| 光山县| 集贤县| 亳州市| 红原县| 盱眙县| 资中县| 龙岩市| 武平县| 广平县| 宜川县| 南川市| 天镇县| 元氏县| 宜宾市| 汉沽区| 天气| 泉州市| 北碚区| 赤城县| 贵州省| 龙里县| 白朗县| 澳门| 芦山县| 屯留县| 图片| 盐边县| 南召县| 昌平区| 西城区| 嘉禾县| 彩票| 阳原县| 丹棱县| 上犹县| 河西区|