Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

SQL Server generates a sql script and performs a sample analysis of restoring the database

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article will explain in detail the example analysis about SQL Server generating sql script and implementing restore database, the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

Last time, I introduced how to restore database files through bak files. Today, we will introduce how to back up and restore new databases by exporting sql scripts. However, this method is more suitable for small and medium-sized data tables with less database data. Let's take SQL Server2012 as an example.

I. back up the database

1. Select a database, right-click, select: task = "generate script"

two。 Select the database objects to be scripted. Note that you can select specific database objects here, and we can select the data tables we need to back up.

3. Select the advanced options in the first step below the current page, and then select the location where the output sql script will be saved.

4. The most important step in the advanced options is to select the first "schema and data" in the "data type of script to be written", which defaults to "schema only". This option replicates only the table structure of the database, not the specific data of the database.

5. We can view the specific exported scripts and data.

Restore the database

1. Create an identical empty database in a new database instance, also named IGIS.

two。 Through: file = "Open the file and open the script file that you just exported.

3. Choose to execute or press F5 to perform the corresponding operation, you can import the data table structure and data in the corresponding database into the new database, and finally complete the backup of the database. (note: here you need to build the database first, and then delete all the statements before creating the table (create table xxx) in the script)

This is the example analysis about SQL Server generating sql script and performing database restore. I hope the above content can be helpful to you and learn more. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report