oracle data export and import
Data export and import
When we use a database, we always hope that the contents of the database are reliable and correct, but due to
computer system failures (hardware failures, software failures, network failures, process failures and system failures)
affecting the operation of the database system, affecting the database The correctness of the data in the database, or even destroy the database, so that
all or part of the data in the database is lost. Therefore, when the above-mentioned failure occurs, it is hoped that the complete database can be reconstructed
. This process is called database recovery, and database backup is necessary for database recovery.
Whole library export and import
Whole library export
Whole library export command
exp 用户/密码 full=y
Add the parameter full=y to export the whole database. The users of the database exported by the whole database need to have the dba permission to export. If all the users who are exported do not have the dba permission, the following prompt will be prompted to re-enter the dba permission when exporting Export the entire database with the user name and password.
After executing the command, a file named EXPDAT.DMP will be generated in the current directory. This file is a backup file.
If you want to specify the name of the backup file, just add the file parameter, the command is as follows
exp 用户/密码 file=文件名 full=y
Whole library import
Whole library import command
imp 用户/密码 full=y
If the file parameter is not specified in this command, the backup file EXPDAT.DMP will be used for import by default
. If the file parameter is specified, the backup file specified by file will be used for recovery
imp 用户/密码 full=y file=文件名
After the execution is successful, you can see the imported table
Export and import by user
Export by user
grammar:
exp 登录的用户名/密码 owner=数据库中的用户名 file=文件名
-- 导出testds用户下的表
exp testds/testds owner=testds file=1.dmp
import by user
grammar:
imp 登录的用户名/密码 file=文件名 fromuser=用户
-- 导入用户testds下的表从1.dmp文件
imp testds/testds file=1.dmp fromuser=testds
Export and import by table
export by table
exp 登录的用户名/密码 file=文件名 tables=表名,表名
Use the tables parameter to specify the tables to be exported. If there are multiple tables, separate them with commas (the commas are for English input methods)
exp testds/testds file=1.dmp tables=departments,employees,t_owners
import by table
imp 登录的用户名/密码 file=文件名 tables=表名,表名
imp testds/testds file=1.dmp tables=departments,employees,t_owners