Statements or methods for mysql/sqlserver/db2/plsql to back up the database

Following are the statements or methods for each database backup:

MySQL

MySQL can be backed up with the following command:

Backup the entire database:

mysqldump -u username -p dbname > backup_file.sql

where username is your MySQL user name, dbname is the name of the database you want to back up, and backup_file.sql is the name of the file you want to save the backup to.

Backup specified tables:

mysqldump -u username -p dbname table1 table2 > backup_file.sql

This will back up the table1 and table2 tables in the dbname database. If you want to backup more tables, list them following the same pattern.

SQL Server

SQL Server backups can be made using the following statements:

Backup the entire database:

BACKUP DATABASE dbname TO DISK='C:\backup_file.bak'

where dbname is the name of the database you want to back up and C:\backup_file.bak is the location where you want to save the backup.

Backup specified tables:

BACKUP TABLE table_name TO DISK='C:\backup_file.bak'

This will back up the table_name table and save it to the file C:\backup_file.bak.

DB2

A DB2 backup can be made using the following command:

Backup the entire database:

db2 backup database dbname to /path/to/backup/dir

where dbname is the name of the database you want to back up and /path/to/backup/dir is the directory location where you want to save the backup.

Backup specified tables:
DB2 does not support backup specified tables, but you can back up specified data sets. The following is an example of backing up the first 10 rows in the table_name table:

db2 "export to /path/to/export/file of del select * from table_name fetch first 10 rows only"

PL/SQL

PL/SQL is a programming language of Oracle, and the expdp command can be used to back up data.
Here is the command to back up a single database:

expdp [用户名]/[密码]@[连接串] schemas=[数据库名] dumpfile=[备份文件名].dmp

Guess you like

Origin blog.csdn.net/qq_42716761/article/details/130099668