开发者

Beginner's SQL: How do I find a detached database?

开发者 https://www.devze.com 2023-03-21 16:11 出处:网络
I\'m brand new to SQL and I\'m practicing some queries with a DB. I\'ve now just detached the database using Tasks > Detach

I'm brand new to SQL and I'm practicing some queries with a DB. I've now just detached the database using Tasks > Detach

Question 1: When I detach a file, I'm guessing it's saved to an 开发者_Go百科MDF file? Where would I locate this file?

Question 2: When I create a new DB, where do the related files get saved? I'm assuming an MDF and an LDF set of files are created.

If it helps, here's my version info

Microsoft SQL Server 2008 (SP1) - 10.0.2531.0 (X64) Mar 29 2009 10:11:52 Copyright (c) 1988-2008 Microsoft Corporation Developer Edition (64-bit) on Windows NT 6.1 (Build 7601: Service Pack 1)

Thanks!


You can always look at the database properties in your Object Explorer in SQL Server Management Studio before detaching - the file(s) will not be moved or anything when detaching....

Beginner's SQL: How do I find a detached database?

In the Properties dialog box, go to the Files section and to your right, the relevant info can be found:

Beginner's SQL: How do I find a detached database?


SQL Server databases are .mdf files. When you detach, the .mdf file is closed by the SQL Server process, but it exists from the moment you create the database. Just to be clear, there is no concept of "saving" in an SQL DBMS; at least, not in the sense you are suggesting. Every transaction you perform is permanently stored from the moment it is committed.

When creating the database, the dialog box shows a list of files that will be created. You may have to resize some of the columns and scroll horizontally to see the full path. You can also see this information by bringing up the database properties dialog.

The .ldf file is the transaction log. It plays a vital role in ensuring the permanency of committed transactions.


Ok so if you have already detached the database, and then realized that you are clueless where it is, you can do this trick.

  1. Expand server, then on Databases click Right Mouse then choose Attach...

  2. Click Add...

  3. Then in the new window that opens will be a path to the directory where your detached database is (if you haven't navigated from default location earlier)

Also, the default location for MSSql databases is:

C:\Program Files\Microsoft SQL Server\[YourSQLVersionGoesHere]\MSSQL\DATA

Beginner's SQL: How do I find a detached database?

Beginner's SQL: How do I find a detached database?

Hope this saves you some time.

0

精彩评论

暂无评论...
验证码 换一张
取 消