欢迎进入Oracle社区论坛,与200万技术人员互动交流 >>进入 一、Oracle跟踪文件 Oracle跟踪文件分为三种类型,一种是后台报警日志文件,记录数据库在启动、关闭和运行期间后台进程的活动情况,如表空间创建、回滚段创建、某些alter命令、日志切换、错误消息等
欢迎进入Oracle社区论坛,与200万技术人员互动交流 >>进入
一、Oracle跟踪文件
Oracle跟踪文件分为三种类型,一种是后台报警日志文件,记录数据库在启动、关闭和运行期间后台进程的活动情况,如表空间创建、回滚段创建、某些alter命令、日志切换、错误消息等。在数据库出现故障时,应首先查看该文件,但文件中的信息与任何错误状态没有必然的联系。后台报警日志文件保存BACKGROUND_DUMP_DEST参数指定的目录中,文件格式为SIDALRT.LOG。另一种类型是DBWR、LGWR、SMON等后台进程创建的后台跟踪文件。后台跟踪文件根据后台进程运行情况产生,后台跟踪文件也保存在BACKGROUND_DUMP_DEST参数指定的目录中,文件格式为siddbwr.trc、sidsmon.trc等。还有一种类型是由连接到Oracle的用户进程(Server Processes)生成的用户跟踪文件。这些文件仅在用户会话期间遇到错误时产生。此外,用户可以通过执行oracle跟踪事件(见后面)来生成该类文件,用户跟踪文件保存在USER_DUMP_DEST参数指定的目录中,文件格式为oraxxxxx.trc,xxxxx为创建文件的进程号(或线程号)。
二、Oracle跟踪事件
Oracle提供了一类命令,可以将Oracle各类内部结构中所包含的信息转储(dump)到跟踪文件中,以便用户能根据文件内容来解决各种故障。设置跟踪事件有两种方法,一种是在init.ora文件中设置事件,这样open数据库后,将影响到所有的会话。设置格式如下:
EVENT="eventnumber trace name eventname [forever,] [level levelnumber] : ......." |
通过:符号,可以连续设置多个事件,也可以通过连续使用event来设置多个事件。
另一种方法是在会话过程中使用alter session set events命令,只对当前会话有影响。设置格式如下:
alter session set events '[eventnumber|immediate] trace name eventname [forever] [, level levelnumber] : .......' |
通过:符号,可以连续设置多个事件,也可以通过连续使用alter session set events 来设置多个事件。
格式说明:eventnumber指触发dump的事件号,事件号可以是Oracle错误号(出现相应错误时跟踪指定的事件)或oralce内部事件号,内部事件号在10000到10999之间,不能与immediate关键字同用。
immediate关键字表示命令发出后,立即将指定的结构dump到跟踪文件中,这个关键字只用在alter session语句中,并且不能与 eventnumber、forever关键字同用。
trace name 是关键字。
eventname指事件名称(见后面),即要进行dump的实际结构名。若eventname为context,则指根据内部事件号进行跟踪。
forever关键字表示事件在实例或会话的周期内保持有效状态,不能与immediate同用。
level为事件级别关键字。但在dump错误栈(errorstack)时不存在级别。
levelnumber表示事件级别号,一般从1到10,1表示只dump结构头部信息,10表示dump结构的所有信息。
1、buffers事件:dump SGA缓冲区中的db buffer结构
alter session set events 'immediate trace name buffers level 1'; --表示dump缓冲区的头部。 |
2、blockdump事件:dump数据文件、索引文件、回滚段文件结构
alter session set events 'immediate trace name blockdump level 66666'; --表示dump块地址为6666的数据块。 |
在Oracle 8以后该命令已改为:
alter system dump datafile 11 block 9; --表示dump数据文件号为11中的第9个数据块。 |
3、controlf事件:dump控制文件结构
alter session set events 'immediate trace name controlf level 10'; --表示dump控制文件的所有内容。 |
4、locks事件:dump LCK进程的锁信息
alter session set events 'immediate trace name locks level 5'; |
5、redohdr事件:dump redo日志的头部信息
alter session set events 'immediate trace name redohdr level 1'; --表示dump redo日志头部的控制文件项。 alter session set events 'immediate trace name redohdr level 2'; --表示dump redo日志的通用文件头。 alter session set events 'immediate trace name redohdr level 10'; --表示dump redo日志的完整文件头。 |
注意:redo日志的内容dump可以采用下面的语句:
alter system dump logfile 'logfilename'; |
6、loghist事件:dump控制文件中的日志历史项
alter session set events 'immediate trace name loghist level 1'; --表示只dump最早和最迟的日志历史项。
levelnumber大于等于2时,表示2的levelnumber次方个日志历史项。
alter session set events 'immediate trace name loghist level 4'; --表示dump 16个日志历史项。
7、file_hdrs事件:dump 所有数据文件的头部信息
alter session set events 'immediate trace name file_hdrs level 1'; --表示dump 所有数据文件头部的控制文件项。 alter session set events 'immediate trace name file_hdrs level 2'; --表示dump 所有数据文件的通用文件头。 alter session set events 'immediate trace name file_hdrs level 10'; --表示dump 所有数据文件的完整文件头。 |
8、errorstack事件:dump 错误栈信息,通常Oracle发生错误时前台进程将得到一条错误信息,但某些情况下得不到错误信息,可以采用这种方式得到Oracle错误。
alter session set events '604 trace name errorstack forever'; --表示当出现604错误时,dump 错误栈和进程栈。 |
9、systemstate事件:dump所有系统状态和进程状态
alter session set events 'immediate trace name systemstate level 10'; --表示dump 所有系统状态和进程状态。 |
[1] [2] [3] [4]

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.

SQL commands in MySQL can be divided into categories such as DDL, DML, DQL, DCL, etc., and are used to create, modify, delete databases and tables, insert, update, delete data, and perform complex query operations. 1. Basic usage includes CREATETABLE creation table, INSERTINTO insert data, and SELECT query data. 2. Advanced usage involves JOIN for table joins, subqueries and GROUPBY for data aggregation. 3. Common errors such as syntax errors, data type mismatch and permission problems can be debugged through syntax checking, data type conversion and permission management. 4. Performance optimization suggestions include using indexes, avoiding full table scanning, optimizing JOIN operations and using transactions to ensure data consistency.

InnoDB achieves atomicity through undolog, consistency and isolation through locking mechanism and MVCC, and persistence through redolog. 1) Atomicity: Use undolog to record the original data to ensure that the transaction can be rolled back. 2) Consistency: Ensure the data consistency through row-level locking and MVCC. 3) Isolation: Supports multiple isolation levels, and REPEATABLEREAD is used by default. 4) Persistence: Use redolog to record modifications to ensure that data is saved for a long time.

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

MySQL is suitable for small and large enterprises. 1) Small businesses can use MySQL for basic data management, such as storing customer information. 2) Large enterprises can use MySQL to process massive data and complex business logic to optimize query performance and transaction processing.

InnoDB effectively prevents phantom reading through Next-KeyLocking mechanism. 1) Next-KeyLocking combines row lock and gap lock to lock records and their gaps to prevent new records from being inserted. 2) In practical applications, by optimizing query and adjusting isolation levels, lock competition can be reduced and concurrency performance can be improved.


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 Mac version
God-level code editing software (SublimeText3)

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.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment