Database structure migration with DAC (Data-tier application)

Source: Internet
Author: User

There are many ways to deploy a "null library" that does not contain data from an existing library, extracting its table structure, objects, permissions, and so forth. such as the self-generate scripts feature, custom script extraction creation scripts, etc.

In practical use, I prefer to use the DAC method. In particular, it can be used in conjunction with PowerShell.

what is a DAC and what does it do?

Data-tier applications (DACS) can simplify the development, deployment, and management of data-tier elements that support client-server or multi-tiered applications. Each DAC runs as a single snap-in, running through the development, testing, and production lifecycles of the affiliate application. The DAC definition supports all database objects (such as tables and views) required by the application, as well as the instance objects associated with the database (such as logins). The DAC also includes policies that define the deployment prerequisites for the DAC.

It can be implemented in a very, very official note: data-tier applications

The steps for migrating data structures with a DAC are briefly described below:

1. Create a test library and login. Then extract the library as a DAC package, this process has a wizard, very simple, basic all the way next.

 UseMasterGoCreate Databasedac_testGoCreateLogin Dac_user withPassword='[email protected]'Go Usedac_testGoSelect *  intoTb1 fromsys.objectsSelect *  intoTb2 fromsys.objectsGoCreate UserDac_user forLogin Dac_userexecsp_addrolemember'db_owner','Dac_user'Go

2. Application name need to be aware that it will be used later.

3. Extracting the DAC is not supported by all objects, and the support type restrictions are described in Bol. I have encountered the database has synonyms can not be extracted, can only be deleted, and then extracted.

Then all the way next, get a generated DAC package.

4. Create an empty library on the target instance that does not necessarily have the same name. This library is first registered as a DAC.

5. The registered application name is consistent with the 2.

6. After successful registration, you will see this DAC in Management->data-tier application.

7. Copy the previously generated DAC package to a location that can be accessed on a target instance. Then use upgrade Data-tier application to import this package. All the way next.

8. When finished, various objects in the source library are available. One thing to note is that the login for the target instance being imported is disabled, and the role of user on the target library is not the original db_owner, but public.

Manually set it if you need to use it.

Summary

1. The DAC is a powerful tool with many features.

2. If SQL Server can provide backup Database ... with No_data, there will be no more.

Database structure migration with DAC (Data-tier application)

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.