Import and export of Oracle database commands


1. Export mode (three modes) and command format

1. Full library mode

exp username/password@network service name full=y file=path\filename.dmp log=path\filename.log

2. User mode ( This mode is generally used)

exp username/password@network service name owners=(user1, user2, user3,...) file=path\filename.dmp log=path\filename.log

3, table mode

exp username/password@network service name tables=(table name 1, table name 2, table name 3,...) file=path\filename.dmp log=path\filename.log

4. In addition, you can only export A tablespace

exp username/password@network service name tablespaces=(tablespace 1, tablespace 2, tablespace 3,...) file=path\filename.dmp log=path\filename.log

II. Import mode (Three modes) and command format

1. Full library mode

imp username/password@network service name full=y file=path\filename.dmp log=path\ds110.log

2. User mode (usually use this mode)

imp username/password@network service name file=path\filename.dmp fromuser=exported user name touser=imported user name log=path\ds110.log

3. Table mode

imp username/password@network service name tables=(table name 1, table name 2, table name 3,...) file=path\file name.dmp fromuser=exported user name touser=imported user name log=path\ ds110.log

4. In addition, you can import only a certain tablespace

imp username/password@network service name tablespaces=(tablespace 1, tablespace 2, tablespace 3,…) file=path\filename.dmp fromuser =Exported user name touser =Imported user name log=path\ds110.log 3. Imported

command parameter description

USERID Username/ password Exported user list, that is, from which user the import file is exported TOUSER The imported user list, that is, to which user the FILE import file is a dmp file. SHOW only lists the file content (Y or N), the default is N TABLES List of imported table names IGNORE Whether to ignore errors during import, defaults to N RECORDLENGTH Record length, defaults to operating system-dependent GRANTS Import permissions (Y or N), defaults to Y INCTYPE Whether the imported type is incremental (Y or N), default is N INDEXES import index (Y or N), default is Y

























COMMIT In the import process, whether to import a row of data, submit a row (Y or N), the default is N, that is, after each table is imported, submit

ROWS to import row data (Y or N), the default is Y

PARFILE parameter file name

LOG Whether the output log file

DESTROY overwrites the data file on the tablespace (Y or N) The default is N

INDEXFILE Write table or index information to the specified file

CHARSET The character set of the export file, the default is NLS_LANG

ANALYZE Execute the ANALYZE statement when importing (Y or N) The default is Y

FEEDBACK The progress is displayed every few lines when importing, the default is 0.

Fourth, the exported command parameter description

USERID Username/password

FULL Whether the whole database is imported (Y or N), the default is N

BUFFER data Buffer size

OWNER Exported user list

FILE Export file, is a dmp file

TABLES Table name list to be exported

COMPRESS Whether to compress (Y or N), the default is Y

RECORDLENGTH The length of input and output records, the default is operating system-dependent

GRANTS Export permissions (Y or N), default is Y

INCTYPE whether the exported type is incremental (Y or N), default is N

INDEXES export index (Y or N), default is Y

RECORD Whether to record an incremental or cumulative export (Y or N) in the system SYS.INCEXP, SYS.INCFIL, the default is Y

ROWS Export row data (Y or N), the default is Y

PARFILE parameter file name

CONSTRAINTS Whether to export constraints, (Y or N), the default is Y

CONSISTENT Whether to add a transaction when performing the export operation (Y or N), the default is N

LOG Output log file

STATISTICS Execute the ANALYZE statement when exporting (Y or N) The default is Y

DIRECT direct path (N)

FEEDBACK displays the progress in each row when exporting, the default is 0.

5. Exported objects

1. Full library module All database objects except sys users

can be exported, including: tablespace definition, configuration file, user-defined , role, system permission authorization, role authorization, default role, resource costs, definition of rolling segment, database link, virtual column, all directory aliases, all external function libraries, all object types, all cluster definitions; for each table, Also export object type definitions used by tables, table definitions, table data, nested table data, table indexes, table constraints, table authorizations, analysis tables, column and table comments, audit information, all referenced integrity constraints, all synonyms , all views, all stored procedures, packages, functions, all triggers, analysis clusters, snapshots, jobs, all refresh groups and children

2, user modules

Object type, database link, sequence, cluster definition, and for each table, the object type definition used by the table, table definition, table data, nested table data, table index, table constraint, table authorization, analysis table, Column and table comments, audit information, integrity constraints referenced by tables belonging to the current user, synonyms, views, stored procedures, packages, functions, triggers, analysis clusters, snapshots, jobs, refresh groups

3, table schemas

, exportable tables Object type definitions used, table definitions, table data, nested table data, table indexes, table constraints, table authorizations, analytical tables, column and table comments, audit information, integrity constraints on table references, triggers, and export Triggers owned by other users, indexes of other users

6. Import order

1, character set

2, table definition

3, table data

4, table index

5, integrity constraints, triggers, bitmap index

6, views, functions , Process

7, Package

7. Advanced application

1. When loading data into an existing table, the parameter IGNORE = Y must be used

2. How to add the condition Exp when exporting the table

Username/password@network service name file= Path\file name.dmp tables=(table name) query = \”condition\”

3.

Eight, system objects included in the import of the whole library

Configuration file profiles

Public database link

Synonyms

Role Definition

of rolling segments

system audit options

System permissions

Tablespace definition

tablespace quotas

User definition

Directory alias

9. Possible problems of import tool

imp

If the object already exists, according to the default imp parameter, the import will fail; if the parameter ignore=y is used, the data content in the exp file will be imported; if the table has a unique keyword constraint, the unqualified conditions will not be imported , if the table does not have the constraint of the unique key, it will cause the records to be duplicated

. 2. The database object has primary and foreign key constraints.

This occurs when several DMP files containing tables are imported into the database respectively. If the primary and foreign key constraints are not met, the data will be deleted. Import failed; solution: first import the main table, and then import the dependent table; disable the primary and foreign key constraints of the target import object, after importing the data, then enable

them         

The user of the import operation needs to have the imp_full_database permission 4.

When importing a large table (greater than 80M), the storage allocation fails

If there is a large data block in a row, the import will fail. When exporting a large table of more than 80M, remember to compress=N, it will not cause this kind of error.

5. The character sets used by imp and exp are different.

If character sets are different, the import will fail. , You can change the unix environment variable or NLS_LANG related information in the NT registry, and then change it back after the import is complete.

6. The imp and exp versions are not compatible

imp can successfully import files generated by low version exp, but cannot import files generated by high version exp



10. Export from one account and import from another account

Export table schema example:

1 Export PRNBSN_CONTENTTEMPLATE and PRNBSN_RELINFOCONTENT two tables from the dbo_pwcdb account without data

exp dbo_pwcdb/dbo_pwcdb@BSY2-NQQX-IP50 file=d:\daochu_noData.dmp tables=

(PRNBSN_CONTENTTEMPLATE,PRNBSN_RELINFOCONTENT) rows=n;

2 Import dbo_smydb account

imp dbo_smydb/dbo_smydb@BSY2-SMY-IP11 full=y file=d: \daochu_noData.dmp touser=dbo_smydb ignore=y;



11. Export and import triggers, stored procedures, sequences, indexes and other objects with the help of PL/SQL Developer tools.

1 Log in to the PL/SQL Developer tool with account A, select Tools ---> Export User Object in the menu

2 Take exporting a stored procedure as an example, select the following image:

image



In the procedure object, select the stored procedure object to be exported, and set Output the file name and click Export.

3 If there is an account with the same name in the oracle library that needs to be imported, you can create a new command window directly, then copy the content of fun_proc. import;

  If the oracle library to be imported is an account with another name, such as account B. Then you need to open the fun_proc.sql file, find all A account names and replace them with B accounts, and then use the B account to log in to the PL/SQL Developer tool, create a new command window, paste the contents of the file, and execute.

    Note: The generated stored procedure name will be in the following form: Create procedure account A. Stored procedure name, so it needs to be replaced with Create procedure account B. Stored procedure name. Open it and you will understand.

   For the import of other objects, refer to the way of importing stored procedure objects.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326490826&siteId=291194637
Recommended