Mssql database operation manual

Source: Internet
Author: User
Mssql database operation manual 1. Back up the database 1. Open SQL Enterprise Manager, open the Microsoft SQL Server 2 and SQL Server group in the root directory of the console. Double-click your server. Double-click the database directory. 3. Select Your Database Name (such as the system database Newasp) -- click the tool in the menu above -- select backup data

Mssql database operation manual 1. Back up the database 1. Open SQL Enterprise Manager, open Microsoft SQL Server 2 and SQL Server group in the root directory of the console. Double-click your Server. Double-click the database directory. 3. Select Your Database Name (such as system database Newasp) -- click the tool in the menu above -- select backup data

Mssql database operation manual

I. Back up the database

1. Open SQL Enterprise Manager and click Microsoft SQL Server in the root directory of the console.
2. SQL Server group --> double-click to open your Server --> double-click to open the database directory
3. Select Your Database Name (such as the system database Newasp) --> click the tool in the menu above --> select backup database
4. Select full backup as the backup option. If there is a path or name for the backup in the target project, click Delete and then add. If there is no path or name, select Add directly, specify the path and file name, click OK to return to the backup window, and click OK to back up

2. Restore the database

1. Open SQL Enterprise Manager and click Microsoft SQL Server in the root directory of the console.
2. SQL Server group --> double-click to open your Server --> click the new database icon in the icon bar to retrieve the name of the new database.
3. Click the new database name (such as the system database Newasp) --> click the tool in the menu above --> select recover Database
4. In the displayed window, select "restore from device"> "select device"> "add"> "select your backup file name"> "add" and click "OK" to return, at this time, the device column should display the database backup file name you just selected. The default backup number is 1. (If you have backed up the same file multiple times, click View next to the backup number, select the latest backup in the check box and click OK) --> then click the option button next to the general button
5. In the displayed window, select force restore on the existing database, and select the option to enable the database to continue running but not to restore other transaction logs in the recovery completion status. To restore the database file in the middle of the window, you need to set it according to your SQL installation (you can also specify your own directory). The logical file name does not need to be changed, the physical file name should be changed based on the recovered machine. If your SQL database is installed in D: Program FilesMicrosoft SQL ServerMSSQLData, you can change the directory of the recovered machine, and the final file name should be changed to your current database name (for example, NewCloud_data.mdf, Newasp database, Newasp_data.mdf ), log and data files must be modified in this way (the log file name is * _ log. ldf ends). You can set the recovery directory as needed, provided that the directory must exist (for example, you can specify d: sqldataNewCloud_data.mdf or d: sqldataNewCloud_log.ldf). Otherwise, an error is returned.
6. After the modification is complete, click "OK" below to restore. a progress bar is displayed, prompting the recovery progress. After the restoration is complete, the system will automatically prompt "success". If an error is reported in the middle, please record the relevant error content and ask people familiar with SQL operations. The common error is nothing more than a directory error, repeated file names, incorrect file names, insufficient space, or database in use errors, you can close all SQL windows and re-open them to restore the database. If an error is prompted, stop the SQL Service and restart it, as for the above other errors, you can change the content of the errors to restore them.

Iii. Database shrinking

In general, the contraction of the SQL database does not greatly reduce the size of the database. Its main function is to shrink the log size. This operation should be performed on a regular basis to avoid excessive database logs.
1. Set database mode to simple mode: Open the SQL Enterprise Manager, in the root directory of the console, open Microsoft SQL Server --> SQL Server group --> double-click your Server --> double-click to open the database directory --> select your database name (such as the system database) newasp) --> then right-click and select Properties --> Select Options --> select "simple" in the fault recovery mode, and click OK to save
2. Right-click the current database to view the shrinking database in all tasks. Generally, the default settings in the database do not need to be adjusted. Click OK directly.
3. After shrinking the database, we recommend that you set your database attributes to the standard mode. The operation method is the same as the first one, because logs are often an important basis for restoring the database in case of exceptions.

4. Set daily automatic Database Backup

We strongly recommend that users with conditions perform this operation!
1. Open the Enterprise Manager and click Microsoft SQL Server> SQL Server group in the root directory of the console. Double-click to open your Server.
2. Click Tools in the menu above --> select Database Maintenance Scheduler
3. Next, select the data to be automatically backed up --> next, update the data optimization information. You do not need to select here --> next, check data integrity.
4. Next, specify the database maintenance plan. The default one-week backup is performed. Click "change" and select "backup every day". Click "OK ".
5. Next, specify the backup disk directory and select the specified directory. For example, you can create a directory on disk d, such as d: databak, and then select to use this directory here, if you have a large number of databases, it is best to create a subdirectory for each database, and then select the number of days before the deletion of the backup, generally set to 4-7 days, depending on your specific backup requirements, the backup file extension is generally bak and the default is used.
6. Specify the transaction log backup plan in the next step. Check whether you need to select the report to be generated in the next step. Generally, do not select the report, it is best to use the default option --> next step to complete
7. After completion, the system will probably prompt that the SQL Server Agent service is not started. First, click confirm to complete the plan settings, find the SQL green icon in the rightmost status bar of the desktop, and double-click it, select SQL Server Agent from the service list, and click the run arrow to automatically start the service when the OS is started.

8. At this time, the database plan has been successfully run and will be automatically backed up according to the above settings.

Modify plan:
1. Open the Enterprise Manager, in the root directory of the console, choose Microsoft SQL Server> SQL Server group> double-click your Server> Manage> database maintenance plan. plan, can be modified or deleted

5. Data Transfer (new database or transfer server)

In general, it is best to use backup and restoration operations to transfer data. In special cases, you can use the Import and Export Method for transfer. Here we will introduce the Import and Export method, the data import/export method can be used to reduce or contract the database size when the database contraction is invalid. By default, this operation provides you with a certain understanding of SQL operations, if you do not understand some of these operations, you can consult the relevant staff of the mobile network or query online materials.
1. Export all tables and stored procedures of the original database into an SQL file, when exporting data, make sure to select the options to compile the index script and write the primary key, foreign key, default value, and check the constraints script.
2. Create a database and execute the SQL File Created in step 1 for the new database.
3. Use SQL to import and export all the table content in the original database to the new database.

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.