1. 程式人生 > 實用技巧 >LeetCode 129. 求根到葉子節點數字之和

LeetCode 129. 求根到葉子節點數字之和

1、百度的執行sql語句執行變更mdf檔案,效果不理想。搞得資料庫直接不能訪問了。

 --檢視當前的存放位置
  select database_id,name,physical_name AS CurrentLocation,state_desc,size
  from sys.master_files 
  where database_id=db_id(N'資料庫名');
  
  --修改檔案的存放位置下次啟動生效
  --test為資料庫名,
  alter database 資料庫名 modify file ( name = 檔名(不包含字尾), filename = '檔案儲存路徑');
  alter database 資料庫名 modify file ( name = 檔名(不包含字尾), filename = '檔案儲存路徑');
 
 alter database testDb modify file ( name = test, filename = 'G:\SQL_DATA\test\test.mdf');
 alter database testDb modify file ( name = test_log, filename = 'G:\SQL_DATA\test\test_log.ldf');

 

2、考慮分離附加即可

(1)、選擇要變更資料檔案mdf的資料庫。右鍵分離

(2)、找到資料檔案原有目錄(分離前可以看下資料庫右鍵-屬性-檔案選項中有)copy mdf檔案到新的目錄下即可

(3)、刪除資料庫即可,資料庫列表重新整理。

(4)、資料庫右鍵-附加

進入到附加資料庫彈出框,新增 按鈕 選擇剛才更換到新目錄中的mdf檔案即,點選確認

(5)、資料庫刷新出來了。這樣即可變更mdf資料檔案和log日誌檔案了。這樣操作,比較保險。