浅析Oracle对象和数据的导入导出
对于Oracle对象和数据的导入导出,我们会用到一些小工具。以前我们一般都是使用PL/SQL Developer来实现,但是PL/SQL Develop
对于Oracle对象和数据的导入导出,我们会用到一些小工具。以前我们一般都是使用PL/SQL Developer来实现,,但是PL/SQL Developer在导出、导入数据时有两个问题:
1、要把表数据和对象(存储过程、视图)分开导出
2、导出的视图如果有注释,那么在导入时常常会出错。
其实,PL/SQL的导出、导入功能使用的是Oracle自带的工具:exp和imp,这两个工具的导出导入数据时提供了很多功能,PL/SQL 只是使用其中的一些功能。下面对它们简单介绍一下:
1 exp/imp使用方法及实例
exp/imp为一种数据库备份恢复工具也可以作为不同数据库之间传递数据的工具两个数据库所在的操作系统可以不同exp 可以将数据库数据导出为二进制文件imp 可以将导出的数据文件再导入到相同的数据库或不同的数据库
数据库导出有四种模式full(全库导出), owner(用户导出), table(表导出), tablespace(表空间导出).
full( 全库导出): 导出除ORDSYS,MDSYS,CTXSYS,ORDPLUGINS,LBACSYS 这些系统用户之外的所有用户的数据.
owner( 用户导出): 导出某个或某些用户的所有权限和数据.
tables( 表导出): 导出某些表(可以是不同用户的)的结构和数据.
tablespace( 表空间导出):表空间导出数据.
执行exp 有三种方法:交互式,命令行和参数文件
交互式:直接输入exp 命令用户可以按照exp 提示的信息一步一步操作,比较简单.
命令行:输入命令行exp username/password parameter=value.
参数文件:输入命令行exp username/password parfile=filename exp 所需的参数从参数文件引入.
参数是可以重复的优先级为命令行优于参数文件后面的参数值覆盖于前面的参数值.
参数介绍
详细的介绍可通过exp help=y或imp helpe=y来查看。下面只对一些常用的参数进行说明。
buffer 缓冲区大小如果此值设为0 则一次只导入一条记录对数据量大的导出可以设置较大一般缺省值即可.
file 导出的文件列表可以指定一个或多个文件名缺省扩展名为.dmp 缺省导出文件名为expdat.dmp.
filesize exp 导出文件的最大字节数超出时从文件列表中获取下一个文件名,没有,则提示输入新的文件名.
help 显示export 参数帮助信息
inctype 增量备份的类型:complete(完全),cumulative(累积)和incremental (增量).
只可以在全库导出模式下才可以做完全累积或增量导出累积导出只导出自上次累积导出或完全导出以来已经修改的表增量导出只导出自上次增量累积或完全导出以来已经修改的表完全导出将数据库中全部对象都导出不管是否以及何时被修改.
log:日志文件,一般如果以命令行导入时,将log 设置上比较好可以看,到所有的导入信息,导入信息哪儿出错,导入了那些数据库对象.
show(imp):只是用来显示备份数据文件的内容.
full:为Y 时表示在全库方式下导出缺省为N.
tables:导出的表列表可以指定一个或多个表名.
fromuser(imp):可以将导出文件中的一个用户模式的数据对象导入为另一个用户模式的对象此参数表示导出文件中的用户模式.
touser(imp):此参数表示导入到数据库中时使用的用户模式对象譬如使用全库或者用户模式导出caittmdba用户的所有对象到一个文件中导 入时需要将用户模式名称改为caittmdba1此时fromuser 为caittmdba,touser 为caittmdba1

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

The method to solve the Oracle cursor closure problem includes: explicitly closing the cursor using the CLOSE statement. Declare the cursor in the FOR UPDATE clause so that it automatically closes after the scope is ended. Declare the cursor in the USING clause so that it automatically closes when the associated PL/SQL variable is closed. Use exception handling to ensure that the cursor is closed in any exception situation. Use the connection pool to automatically close the cursor. Disable automatic submission and delay cursor closing.

In Oracle, the FOR LOOP loop can create cursors dynamically. The steps are: 1. Define the cursor type; 2. Create the loop; 3. Create the cursor dynamically; 4. Execute the cursor; 5. Close the cursor. Example: A cursor can be created cycle-by-circuit to display the names and salaries of the top 10 employees.

SQL statements can be created and executed based on runtime input by using Oracle's dynamic SQL. The steps include: preparing an empty string variable to store dynamically generated SQL statements. Use the EXECUTE IMMEDIATE or PREPARE statement to compile and execute dynamic SQL statements. Use bind variable to pass user input or other dynamic values to dynamic SQL. Use EXECUTE IMMEDIATE or EXECUTE to execute dynamic SQL statements.

Solutions to Oracle cannot be opened include: 1. Start the database service; 2. Start the listener; 3. Check port conflicts; 4. Set environment variables correctly; 5. Make sure the firewall or antivirus software does not block the connection; 6. Check whether the server is closed; 7. Use RMAN to recover corrupt files; 8. Check whether the TNS service name is correct; 9. Check network connection; 10. Reinstall Oracle software.

An AWR report is a report that displays database performance and activity snapshots. The interpretation steps include: identifying the date and time of the activity snapshot. View an overview of activities and resource consumption. Analyze session activities to find session types, resource consumption, and waiting events. Find potential performance bottlenecks such as slow SQL statements, resource contention, and I/O issues. View waiting events, identify and resolve them for performance. Analyze latch and memory usage patterns to identify memory issues that are causing performance issues.

Triggers in Oracle are stored procedures used to automatically perform operations after a specific event (insert, update, or delete). They are used in a variety of scenarios, including data verification, auditing, and data maintenance. When creating a trigger, you need to specify the trigger name, association table, trigger event, and trigger time. There are two types of triggers: the BEFORE trigger is fired before the operation, and the AFTER trigger is fired after the operation. For example, the BEFORE INSERT trigger ensures that the age column of the inserted row is not negative.
