1. Export the database test completely, and the username System Password Manager is exported to D: daochu. dmp.
Exp system/manager @ test file = D: daochu. dmp full = y
2. Export the tables of system users and SYS users in the database
Exp system/manager @ test file = D: daochu. dmp owner = (system, sys)
3. Export the inner_policy and policy_staff_relat tables in the database.
Exp aichannel/aichannel @ testdb2 file = D: datanewsmgnt. dmp tables = (inner_policy, policy_staff_relat)
4. Export the data with the field filed1 in table 1 in the database starting with "00"
Exp system/manager @ test file = D: daochu. dmp tables = (Table1) query = "where filed1 like '201312 '"
The above is a commonly used export. For compression, you can use WinZip to compress the DMP file.
You can also add compress = Y to the command above.
Data Import
1. import data from D: daochu. dmp to the test database.
IMP system/manager @ test file = D: daochu. dmp
IMP aichannel/aichannel @ HUST full = y file = D: datanewsmgnt. dmp ignore = y
The above may be a problem, because some tables already exist, and then it will report an error, the table will not be imported.
Add ignore = Y to the end.
2. Import table 1 in D: daochu. dmp
IMP system/manager @ test file = D: daochu. dmp tables = (Table1)
The preceding import and export operations are sufficient. In many cases, you must first completely delete the table and then import it.
Note:
If the operator has sufficient permissions, a prompt is displayed.
Databases can be connected. You can use tnsping test to obtain whether the database test can be connected.
Appendix 1:
Add data import permissions to users
First, start SQL * puls
Second, log in with system/Manager
Third, create user username identified by password (this step can be omitted if you have already created a user)
Fourth, grant create user, drop user, alter user, create any view,
Drop any view, exp_full_database, imp_full_database,
DBA, connect, resource, create session to Username
Fifth, run-cmd-to enter the directory where the DMP file is located,
IMP userid = system/manager full = y file = *. dmp
Or imp userid = system/manager full = y file = filename. dmp
Example:
F: workoracle_databackup> imp userid = test/test full = y file = inner_policy.dmp
Screen Display
Import: Release 8.1.7.0.0-production on Thursday February 16 16:50:05 2006
(C) Copyright 2000 Oracle Corporation. All rights reserved.
Connect to: Oracle8i Enterprise Edition Release 8.1.7.0.0-Production
With the partitioning Option
Jserver release 8.1.7.0.0-Production
Export the files created by export: v08.01.07 in the normal path
The zhs16gbk Character Set and zhs16gbk nchar character set have been imported.
The export server uses the utf8 nchar character set (possible ncharset conversion)
. Importing aichannel object to aichannel
.. Importing table "inner_policy" 4 rows
Prepare to enable constraints...
Import is terminated successfully, but a warning is displayed.
Appendix 2:
Oracle cannot directly change the table owner. Export/Import can be used to achieve this purpose.
First create import9.par,
The command is as follows: IMP parfile =/filepath/import9.par
The content of import9.par is as follows:
Fromuser = tgpms
Touser = tgpms2 (Note: You can change the table owner from fromuser to touser. Users of fromuser and touser can be different)
Rows = y
Indexes = y
Grants = y
Constraints = y
Buffer= 409600
File =/backup/ctgpc_20030623.dmp
Log =/backup/import_20030623.log
Supplement: adding feedback = 1000 in the Import/Export command can display an increasing number of "..." in the process to change the blinking cursor.
In short, Oracle Database Export (exp)/import (IMP)
Exp
The database objects are downloaded as DMP files in binary format to facilitate data migration.
Buffer: the buffer for downloading data, in bytes. It is dependent on the operating system by default.
Consistent: the data involved during the download process is read only. The default value is N.
Direct: Use the pass-through method. The default value is N.
Feeback: displays the number of processing records. The default value is 0, that is, it is not displayed.
File: output file. The default value is expdat. dmp.
Filesize: size of the output file. The default value is the maximum value of the operating system.
Indexes: whether to download the index. The default value is N, which indicates the index definition rather than data. Exp does not download the index data.
Log: log file. The default value is none. It is displayed in standard output.
Owner: Specifies the downloaded user name.
Query: select a subset of records.
Rows: Indicates whether to download table records.
Tables: List of output table names
Export the entire instance
Exp dbuser/Oracle file = oradb. dmp log = oradb. Log full = Y consistent = y direct = y
The user shall have DBA Permissions
Export all objects of a user
Exp dbuser/Oracle file = dbuser. dmp log = dbuser. Log owner = dbuser buffer = 4096000 feedback = 10000
Export one or more tables
Exp dbuser/Oracle file = dbuser. dmp log = dbuser. Log tables = Table1, Table2 buffer = 4096000 feedback = 10000
Export some data of a table
Exp dbuser/Oracle file = dbuser. dmp log = dbuser. Log tables = Table1 buffer = 4096000 feedback = 10000 query =/"where col1 = /'... /'And col2/<... /"
Cannot be used for nested tables
Export a table using multiple fixed-size files
Exp dbuser/Oracle file = 1.dmp, 2.dmp, 3.dmp ,... Filesize = 1000 m tables = EMP buffer = 4096000 feedback = 10000
This method is usually used when the table data volume is large and a single dump file may exceed the limit of the file system.
Pass-through path
Direct = Y, replace the buffer option, and the query option is unavailable
Improves download speed
Consistent options
After the export is started, consistent = y freezes updates to the Data Objects of the export operation from other sessions, so as to ensure the consistency of the dump results. However, this process cannot be too long to prevent the rollback segment and the online log consumption from being completed.
IMP
Upload the DMP file downloaded by exp to the database.
Buffer: Upload data buffer, in bytes, which is dependent on the operating system by default
Commit: whether to submit the uploaded records in the data buffer.
Feeback: displays the number of processing records. The default value is 0, that is, it is not displayed.
File: input file. The default value is expdat. dmp.
Filesize: size of the input file. The default value is the maximum value of the operating system.
Fromuser: Specifies the source user
Ignore: whether to ignore the object creation error. The default value is N. It is normal that the object has been created before upload. Therefore, we recommend that you set this option to y.
Indexes: whether to upload an index. The default value is N, which indicates the index definition rather than data. If the index has been created during the upload, this option is invalid even if it is N. IMP automatically updates the index data.
Log: log file. The default value is none. It is displayed in standard output.
Rows: whether to upload table records
Tables: List of input table names
Touser: Specify the target user
Import the entire instance
IMP dbuser/Oracle file = oradb. dmp log = oradb. Log full = y buffer = 4096000 commit = y ignore = y feedback = 10000
Import all objects of a user
IMP dbuser/Oracle file = dbuser. dmp log = dbuser. Log fromuser = dbuser touser = dbuser2 buffer = 2048000 commit = y ignore = y feedback = 10000
Import one or more tables
IMP dbuser2/Oracle file = user. dmp log = user. Log tables = Table1, Table2 fromuser = dbuser touser = dbuser2 buffer = 2048000 commit = y ignore = y feedback = 10000
Import a table using multiple fixed-size files
IMP dbuser/Oracle file =/(1.dmp, 2.dmp, 3.dmp ,... /) Filesize = 1000 m tables = EMP fromuser = dbuser touser = dbuser2 buffer = 4096000 commit = y ignore = y feedback = 10000