How to attach a detached query database? Go

Source: Internet
Author: User

Introduction

Some time, due to log corruption and other reasons, caused the database query. If you separate the database at this point, you will find that you can no longer attach the database, the consequences are very serious. So this article provides a way to make the database query and isolate the instance, still can be attached in a hack way.

Specific Steps

There is currently a database attchsuspectdatabase, with only one table test, where there is only one column of int columns, where data is currently 1, 2. We have questioned this database, as shown in 1.

Figure 1: Database query

At this point, after we detach the database. Attempt to attach, display failed, 2 shown.

Figure 2: The database is no longer attached

Even if we use methods such as rebuilding the log, the discovery still cannot be attached, as shown in 3.

Figure 3: Attempt to rebuild log method append, still invalid

That because the question is the log causes the question, we deleted the log to attach the database directly?

Figure 4: Delete log append, still invalid

At this point, we attach the database by a hack method. First, we create a database with the same name and then thread the database down, and the code looks like this:

ALTER DATABASE [attchsuspectdatabase] SET OFFLINE;
GO

Replace the original database MDF file with the MDF file of the newly created puppet database, at which point the database is attached successfully, but the status is still questioned, as shown in 5.

Figure 5. Hack method attached database succeeded

At this point, we can repair the database by normal means. 6 is shown

At this point, the database with some tips to attach the query is complete.

http://www.cnblogs.com/CareySon/p/3509030.html [Turn]

How to attach a detached query database? Go

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.