iT邦幫忙

0

第33天~還原資料庫

Tzu 2022-02-07 00:12:382814 瀏覽
  • 分享至 

  • xImage
  •  

這個的上一篇:https://ithelp.ithome.com.tw/articles/10283889

又是練習MS-SQL 也有人叫T-SQL

連線至伺服器的圖案-可以按"插頭"的圖案

https://ithelp.ithome.com.tw/upload/images/20220207/20119035CPIjVChqie.png

寫程式開發-一定會用到資料庫-

https://ithelp.ithome.com.tw/upload/images/20220207/20119035tQwi1WkdAH.png

功能正常可以不用升級~
https://ithelp.ithome.com.tw/upload/images/20220207/20119035CrQ2tdqZjk.png

三層-
https://ithelp.ithome.com.tw/upload/images/20220207/20119035dv0ACFG0w2.png

外部層-

https://ithelp.ithome.com.tw/upload/images/20220207/201190354kaEh4RE3a.png

跟T-SQL對照-就是檢視-view

https://ithelp.ithome.com.tw/upload/images/20220207/20119035JVPF7YZjIV.png

要看要按右鍵-新增檢視-
https://ithelp.ithome.com.tw/upload/images/20220207/20119035ijuCGKqCzY.png

點開會看到-

https://ithelp.ithome.com.tw/upload/images/20220207/20119035OISyt8KaUy.png


概念層-
https://ithelp.ithome.com.tw/upload/images/20220207/20119035uthLtR3YU2.png

跟T-SQL對照-就是資料表-
https://ithelp.ithome.com.tw/upload/images/20220207/20119035CcjwiDZRHU.png

綱要Schema-例如蓋大樓前要有施工藍圖-資料表=宣告變數=int age;

https://ithelp.ithome.com.tw/upload/images/20220207/20119035pT4JLjSKpr.png

https://ithelp.ithome.com.tw/upload/images/20220207/20119035oZxeB2OIiK.png

https://ithelp.ithome.com.tw/upload/images/20220207/20119035Jj8A8I9Pic.png

年齡跟生日可以從外部寫公式對照/電話是敏感性資料不公開-

https://ithelp.ithome.com.tw/upload/images/20220207/20119035FBcrw0l2KZ.png
關SQL是按右鍵-停止=維護時用=銀行暫停使用
https://ithelp.ithome.com.tw/upload/images/20220207/20119035DH7f4nCl6Q.png


新增資料表-
https://ithelp.ithome.com.tw/upload/images/20220207/20119035fBsBciMw2S.png

https://ithelp.ithome.com.tw/upload/images/20220207/20119035CSncxUXqgK.png

查看-指令碼-

https://ithelp.ithome.com.tw/upload/images/20220207/20119035leoalWtxFr.png

只要留下第一行.其他刪掉-按執行
https://ithelp.ithome.com.tw/upload/images/20220207/20119035q6IgHGzizg.png
/images/emoticon/emoticon08.gif
https://ithelp.ithome.com.tw/upload/images/20220207/20119035aQzVKd8Ox7.png

重新整理會看到資料庫-
https://ithelp.ithome.com.tw/upload/images/20220207/20119035XoFsZ2ZoGR.png


刪除資料庫-按右鍵-刪除-X會直接刪掉

https://ithelp.ithome.com.tw/upload/images/20220207/20119035eanXHF5Bor.png

也可以-看到這樣-再看到-指令碼-原來的視窗按X
https://ithelp.ithome.com.tw/upload/images/20220207/20119035yL8cIBYywB.png

按執行-長這樣
https://ithelp.ithome.com.tw/upload/images/20220207/20119035Og1xHa9CMb.png

然後再到 資料表-按重新整理-就沒看到了~
https://ithelp.ithome.com.tw/upload/images/20220207/20119035vFyuJeHrgd.png

現在的公司資料庫是不能帶回家的..........


下載範例
https://docs.microsoft.com/zh-tw/sql/samples/adventureworks-install-configure?view=sql-server-ver15&tabs=ssms

https://ithelp.ithome.com.tw/upload/images/20220207/20119035vA07LmxlUJ.png

檔案不要放在下載會找不到-我的版本號-每個人都不同

https://ithelp.ithome.com.tw/upload/images/20220207/20119035Zt5FIxfhNj.png

要放在-C:\Program Files\Microsoft SQL Server\MSSQL13.SQLEXPRESS\MSSQL\Backup

https://ithelp.ithome.com.tw/upload/images/20220207/20119035xds1zIGo9u.png
直接拖過來~
https://ithelp.ithome.com.tw/upload/images/20220207/20119035cKzYdWYFkg.png


再來按右鍵-還原資料庫-

https://ithelp.ithome.com.tw/upload/images/20220207/20119035ImXM3YFgBB.png

按裝置-

https://ithelp.ithome.com.tw/upload/images/20220207/201190352cCvl5oX0r.png

-依序按2個確定-
https://ithelp.ithome.com.tw/upload/images/20220207/20119035blfAZYC2uq.png

後面開始找到檔案C:\Program Files\Microsoft SQL Server\MSSQL13.SQLEXPRESS\MSSQL\Backup

https://ithelp.ithome.com.tw/upload/images/20220207/20119035FeS66sWo6u.png
只能依序點-不好找

/images/emoticon/emoticon06.gif


然後依序按4個確定
https://ithelp.ithome.com.tw/upload/images/20220207/20119035EtQ2ejFma0.png

目前新增失敗:???
https://ithelp.ithome.com.tw/upload/images/20220207/20119035WxSkKq1S3o.png
可能是新舊版本的問題。

下載的是 2019 的備份檔,若是還原到 SQL Server 2019 版本之前,例如:SQL Server 2017、2016…等舊版就會出問題。

https://ithelp.ithome.com.tw/upload/images/20220207/20119035ZbH1VZjQPc.png

成功~
因為我用2016的~^^
https://docs.microsoft.com/zh-tw/sql/samples/adventureworks-install-configure?view=sql-server-ver15&tabs=ssms

這個的下一篇:https://ithelp.ithome.com.tw/articles/10283907


圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言