对于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

InnoDB uses redologs and undologs to ensure data consistency and reliability. 1.redologs record data page modification to ensure crash recovery and transaction persistence. 2.undologs records the original data value and supports transaction rollback and MVCC.

Key metrics for EXPLAIN commands include type, key, rows, and Extra. 1) The type reflects the access type of the query. The higher the value, the higher the efficiency, such as const is better than ALL. 2) The key displays the index used, and NULL indicates no index. 3) rows estimates the number of scanned rows, affecting query performance. 4) Extra provides additional information, such as Usingfilesort prompts that it needs to be optimized.

Usingtemporary indicates that the need to create temporary tables in MySQL queries, which are commonly found in ORDERBY using DISTINCT, GROUPBY, or non-indexed columns. You can avoid the occurrence of indexes and rewrite queries and improve query performance. Specifically, when Usingtemporary appears in EXPLAIN output, it means that MySQL needs to create temporary tables to handle queries. This usually occurs when: 1) deduplication or grouping when using DISTINCT or GROUPBY; 2) sort when ORDERBY contains non-index columns; 3) use complex subquery or join operations. Optimization methods include: 1) ORDERBY and GROUPB

MySQL/InnoDB supports four transaction isolation levels: ReadUncommitted, ReadCommitted, RepeatableRead and Serializable. 1.ReadUncommitted allows reading of uncommitted data, which may cause dirty reading. 2. ReadCommitted avoids dirty reading, but non-repeatable reading may occur. 3.RepeatableRead is the default level, avoiding dirty reading and non-repeatable reading, but phantom reading may occur. 4. Serializable avoids all concurrency problems but reduces concurrency. Choosing the appropriate isolation level requires balancing data consistency and performance requirements.

MySQL is suitable for web applications and content management systems and is popular for its open source, high performance and ease of use. 1) Compared with PostgreSQL, MySQL performs better in simple queries and high concurrent read operations. 2) Compared with Oracle, MySQL is more popular among small and medium-sized enterprises because of its open source and low cost. 3) Compared with Microsoft SQL Server, MySQL is more suitable for cross-platform applications. 4) Unlike MongoDB, MySQL is more suitable for structured data and transaction processing.

MySQL index cardinality has a significant impact on query performance: 1. High cardinality index can more effectively narrow the data range and improve query efficiency; 2. Low cardinality index may lead to full table scanning and reduce query performance; 3. In joint index, high cardinality sequences should be placed in front to optimize query.

The MySQL learning path includes basic knowledge, core concepts, usage examples, and optimization techniques. 1) Understand basic concepts such as tables, rows, columns, and SQL queries. 2) Learn the definition, working principles and advantages of MySQL. 3) Master basic CRUD operations and advanced usage, such as indexes and stored procedures. 4) Familiar with common error debugging and performance optimization suggestions, such as rational use of indexes and optimization queries. Through these steps, you will have a full grasp of the use and optimization of MySQL.

MySQL's real-world applications include basic database design and complex query optimization. 1) Basic usage: used to store and manage user data, such as inserting, querying, updating and deleting user information. 2) Advanced usage: Handle complex business logic, such as order and inventory management of e-commerce platforms. 3) Performance optimization: Improve performance by rationally using indexes, partition tables and query caches.


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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver Mac version
Visual web development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.