Home Database Mysql Tutorial Oracle中V$session及session相关信息

Oracle中V$session及session相关信息

Jun 07, 2016 pm 05:21 PM

V$session参数 SADDR: session addressSID: session identifier,常用于连接其它列。SERIAL#: sid 会重用,但是同一个sid被重用时

V$session参数

SADDR: session address
SID: session identifier,常用于连接其它列。
SERIAL#: sid 会重用,但是同一个sid被重用时,serial#会增加,不会重复。
AUDSID: audit session id。可以通过audsid查询当前session的sid。select sid from v$session where audsid=userenv('sessionid');
PADDR: process address,关联v$process的addr字段,可以通过这个字段查处当前session对应操作系统的那个进程的id。
USER#: session's user id。等于dba_users中的user_id。Oracle内部进程的user#为0。关联all_usersch的user_id查询username
USERNAME: session's username。等于dba_users中的username。Oracle内部进程的username为空。关联all_usersch的user_id查询username
COMMAND: session正在执行的SQL Id。1代表create table,3代表select。
TADDR: 当前的transaction address。可以用来关联v$transaction的addr字段。
LOCKWAIT: 可以通过这个字段查询出当前正在等待的锁的相关信息。sid & lockwait与v$lock中的sid & kaddr相对应。
STATUS: 用来判断session状态。Active:正执行SQL语句。Inactive:等待操作。Killed:被标注为删除。
SERVER: server type (dedicated or shared)
SCHEMA#: schema user id。Oracle内部进程的schema#为0。
SCHEMANAME: schema username。Oracle内部进程的schemaname为sys。
OSUSER: 客户端操作系统用户名。
PROCESS: 客户端process id。
MACHINE: 客户端machine name。
TERMINAL: 客户端执行的terminal name。
PROGRAM: 客户端应用程序。比如ORACLE.EXE (PMON)或者sqlplus.exe
TYPE: session type (background or user)
SQL_ADDRESS, SQL_HASH_VALUE, SQL_ID, SQL_CHILD_NUMBER: session正在执行的sql statement,和v$sql中的address, hash_value, sql_id, child_number相对应。
PREV_SQL_ADDR, PREV_HASH_VALUE, PREV_SQL_ID, PREV_CHILD_NUMBER: 上一次执行的sql statement。
MODULE, MODULE_HASH, ACTION, ACTION_HASH, CLIENT_INFO: 应用通过DBMS_APPLICATION_INFO设置的一些信息。
FIXED_TABLE_SEQUENCE: 当session完成一个user call后就会增加的一个数值,也就是说,如果session inactive,它就不会增加。因此可以根据此字段的值变化来监控某个时间点以来的session的性能情况。例如,,一个小时以前,某个session的FIXED_TABLE_SEQUENCE是10000,而现在是20000,则表明一个小时内其user call比较频繁,可以重点关注此session的performance statistics。
ROW_WAIT_OBJ#: 被锁定行所在table的object_id。和dba_objects中的object_id关联可以得到被锁定的table name。
ROW_WAIT_FILE#: 被锁定行所在的datafile id。和v$datafile中的file#关联可以得到datafile name。
ROW_WAIT_BLOCK#: Identifier for the block containing the row specified in ROW_WAIT_ROW#
ROW_WAIT_ROW#: session当前正在等待的被锁定的行。
LOGON_TIME: session logon time
ADDR: process address。可以和v$session的paddr字段关联。
PID: Oracle进程identifier。
SPID: 操作系统进程identifier。
USERNAME: 操作系统进程的用户名。并非Oracle用户名。
SERIAL#:: process serial number。
TERMINAL: 操作系统terminal identifier(e.g., computer name)。
PROGRAM: 进程正在执行的程序(e.g., ORACLE.EXE (ARC0)),和v$session中的program类似。
BACKGROUND: 1代表oracle background process,null代表normal process。
查看当前用户的sid和serial#:
select sid, serial#, status from v$session where audsid=userenv('sessionid');
查看当前用户的spid:
select spid from v$process p, v$session s where s.audsid=userenv('sessionid') and s.paddr=p.addr;
select spid from v$process p join v$session s on p.addr=s.paddr and s.audsid=userenv('sessionid');
查看当前用户的trace file路径:
select p.value || '/' || t.instance || '_ora_' || ltrim(to_char(p.spid,'fm99999')) || '.trc'
    from v$process p, v$session s, v$parameter p, v$thread t
    where p.addr = s.paddr and s.audsid = userenv('sessionid') and p.name = 'user_dump_dest';
已知spid,查看当前正在执行或最近一次执行的语句:
select /*+ ordered */ sql_text from v$sqltext sql
    where (sql.hash_value, sql.address) in (
        select decode(sql_hash_value, 0, prev_hash_value, sql_hash_value), decode(sql_hash_value, 0, prev_sql_addr, sql_address)
        from v$session s where s.paddr = (select addr from v$process p where p.spid = to_number('&pid')))
    order by piece asc;
查看锁和等待:
col user_name format a10
col owner format a10
col object_name format a15
col sid format 999999
col serial# format 999999
col spid format a6

linux

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How do you alter a table in MySQL using the ALTER TABLE statement? How do you alter a table in MySQL using the ALTER TABLE statement? Mar 19, 2025 pm 03:51 PM

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

Explain InnoDB Full-Text Search capabilities. Explain InnoDB Full-Text Search capabilities. Apr 02, 2025 pm 06:09 PM

InnoDB's full-text search capabilities are very powerful, which can significantly improve database query efficiency and ability to process large amounts of text data. 1) InnoDB implements full-text search through inverted indexing, supporting basic and advanced search queries. 2) Use MATCH and AGAINST keywords to search, support Boolean mode and phrase search. 3) Optimization methods include using word segmentation technology, periodic rebuilding of indexes and adjusting cache size to improve performance and accuracy.

How do I configure SSL/TLS encryption for MySQL connections? How do I configure SSL/TLS encryption for MySQL connections? Mar 18, 2025 pm 12:01 PM

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? Mar 21, 2025 pm 06:28 PM

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

How do you handle large datasets in MySQL? How do you handle large datasets in MySQL? Mar 21, 2025 pm 12:15 PM

Article discusses strategies for handling large datasets in MySQL, including partitioning, sharding, indexing, and query optimization.

Difference between clustered index and non-clustered index (secondary index) in InnoDB. Difference between clustered index and non-clustered index (secondary index) in InnoDB. Apr 02, 2025 pm 06:25 PM

The difference between clustered index and non-clustered index is: 1. Clustered index stores data rows in the index structure, which is suitable for querying by primary key and range. 2. The non-clustered index stores index key values ​​and pointers to data rows, and is suitable for non-primary key column queries.

When might a full table scan be faster than using an index in MySQL? When might a full table scan be faster than using an index in MySQL? Apr 09, 2025 am 12:05 AM

Full table scanning may be faster in MySQL than using indexes. Specific cases include: 1) the data volume is small; 2) when the query returns a large amount of data; 3) when the index column is not highly selective; 4) when the complex query. By analyzing query plans, optimizing indexes, avoiding over-index and regularly maintaining tables, you can make the best choices in practical applications.

How do you drop a table in MySQL using the DROP TABLE statement? How do you drop a table in MySQL using the DROP TABLE statement? Mar 19, 2025 pm 03:52 PM

The article discusses dropping tables in MySQL using the DROP TABLE statement, emphasizing precautions and risks. It highlights that the action is irreversible without backups, detailing recovery methods and potential production environment hazards.

See all articles