- SQL - Discussion
- SQL - Useful Resources
- SQL - Useful Functions
- SQL - Quick Guide
- SQL - Questions and Answers
- SQL - Datatype Functions
- SQL - Conversion Functions
- SQL - JSON Functions
- SQL - Cursor Functions
- SQL - Logical Functions
- SQL - Statistical Functions
- SQL - Text & Image Functions
- SQL - Numeric Functions
- SQL - Aggregate Functions
- SQL - String Functions
- SQL - Date Functions
- SQL - Database Tuning
- SQL - IN vs EXISTS
- SQL - Group By vs Order By
- SQL - Common Table Expression
- SQL - Cursors
- SQL - Date & Time
- SQL - Auto Increment
- SQL - Using Sequences
- SQL - Handling Duplicates
- SQL - Sub Queries
- SQL - Transactions
- SQL - NULL Values
- SQL - Stored Procedures
- SQL - Default Constraint
- SQL - Check Constraint
- SQL - Null Functions
- SQL - Min & Max
- SQL - Hosting
- SQL - Injection
- SQL - Comments
- SQL - Wildcards
- SQL - Non-Clustered Index
- SQL - Clustered Index
- SQL - Unique Index
- SQL - Primary Key
- - 工会诉Join
- SQL - Inner Join
- SQL - Using Joins
- SQL - Aliases
- SQL - EXCEPT Operator
- SQL - INTERSECT Operator
- SQL - UNION vs UNION ALL
- SQL - UNION Operator
- SQL - BETWEEN Operator
- SQL - NOT NULL
- SQL - IS NOT NULL
- SQL - IS NULL
- SQL - NOT EQUAL
- SQL - NOT Operator
- SQL - CASE
- SQL - EXISTS Operator
- SQL - ANY, ALL Operators
- SQL - IN Operator
- SQL - LIKE Operator
- SQL - BOOLEAN (BIT) Operator
- SQL - AND & OR
- SQL - Having Clause
- SQL - Group By Clause
- SQL - Order By Clause
- SQL - Distinct Clause
- SQL - Top Clause
- SQL - Where Clause
- SQL - Rename Views
- SQL - Drop Views
- SQL - Update Views
- SQL - Create Views
- SQL - Sorting Results
- SQL - Delete Query
- SQL - Update Query
- SQL - Insert Into Select
- SQL - Select Into
- SQL - Select Query
- SQL - Insert Query
- SQL - Constraints
- SQL - Delete Table
- SQL - Drop Table
- SQL - Alter Tables
- SQL - Temporary Tables
- SQL - Clone Tables
- SQL - Truncate Table
- SQL - Rename Table
- SQL - Show Tables
- SQL - Create Table
- SQL - Backup Database
- SQL - Show Database
- SQL - Rename Database
- SQL - Select Database
- SQL - Drop Database
- SQL - Create Database
- SQL - Expressions
- SQL - Operators
- SQL - Data Types
- SQL - Syntax
- SQL - Databases
- SQL - RDBMS Concepts
- SQL - Overview
- SQL - Home
5. 图瓦卢
- 页: 1
- 页: 1
- 结构-创建指数
- 页: 1
- 页: 1
- 页: 1
- SQL - Foreign Key
- 文 件
- ∗ E/CN.6/2009/1。
- 页: 1
- 页: 1
- 文 件
- 页: 1
- 页: 1
- 文 件
- 页: 1
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
SQL - Backup Database
Nowadays, almost every organization uses a database to store information pke employee records, customer records, financial transactions, etc. It is very important to create backups of the database because there might be a chance of data loss due to power surges or disk crashes etc. Overall, regular database backups are essential for ensuring the long-term availabipty of critical data.
Backup database statement in SQL
To create a backup for an existing database, SQL provides us with a simple BACKUP DATABASE command.
Note − We should always back up the database onto a different disk other than the actual database. Even if the disk crashes, we will not lose our backup file along with the database.
Syntax
Following is the syntax of the BACKUP DATABASE command in SQL −
BACKUP DATABASE database_name TO DISK = filepath ;
Example
Firstly, let’s create a database in the SQL server using the following query −
SQL> CREATE DATABASE testDB;
Let’s verify whether the database “testDB” is created or not using the following query −
SQL> SELECT name FROM sys.databases;
The database is successfully created in the SQL server.
+-------+ | name | +-------+ |master | |tempdb | |model | |msdb | |testDB | +-------+
Now, let us try to create a backup file for the database “testDB” inside the “D” drive, named "DB_backup.bak" using the following query.
SQL> BACKUP DATABASE testDB TO DISK = D:DB_backup.bak
Output
When we execute the above query, the output is obtained as follows −
Processed 344 pages for database testDB , file testDB on file 1. Processed 2 pages for database testDB , file testDB_log on file 1. BACKUP DATABASE successfully processed 346 pages in 0.011 seconds (245.383 MB/sec).
Backup Database with SQL DIFFERENTIAL Statement
The SQL Backup with a DIFFERENTIAL Statement is used to create a differential backup of the database. The differential backup contains only the changes made to the database since the last full backup. This type of backup is usually smaller in size compared to a full backup. Thus, it reduces the time to perform the backup.
Syntax
Following is the syntax for the backup database using DIFFERENTIAL Statement −
BACKUP DATABASE database_name TO DISK = filepath WITH DIFFERENTIAL;
Example
Let us look at an example using the DIFFERENTIAL Statement below −
SQL> BACKUP DATABASE testDB TO DISK = D:DB_backup.bak WITH DIFFERENTIAL;
Output
On executing the above query, the output is displayed as follows −
Processed 200 pages for database testDB , file testDB on file 2. Processed 2 pages for database testDB , file testDB_log on file 2. BACKUP DATABASE WITH DIFFERENTIAL successfully processed 202 pages in 0.011 seconds (143.110 MB/sec).Advertisements