Skip to content

Fixed View Definitions (vfixview.sql)

This script reveals the SQL definitions behind Oracle’s fixed views (V$ views), showing how these views are constructed from underlying X$ tables and other internal structures. It’s an invaluable tool for understanding Oracle’s internal architecture, learning how performance views are built, and gaining insight into the data sources behind Oracle’s monitoring capabilities.

rem vfixview.sql
rem
ttitle 'Fixed View Definitions'
rem
col view_name format a30 heading 'VIEW NAME'
col view_definition format a80 heading 'VIEW DEFINITION'
rem
select view_name, view_definition
from v$fixed_view_definition
where view_name like upper('&view')
order by view_name
/
  • View Definition Exposure: Shows the actual SQL behind V$ views
  • Pattern Matching: Supports wildcards to find related views
  • Internal Architecture Insight: Reveals Oracle’s internal data structures
  • Educational Value: Helps understand Oracle’s monitoring framework
  • Troubleshooting Support: Aids in understanding view behavior
  • Development Assistance: Supports custom monitoring development
@vfixview.sql

Input Parameters:

  • view: View name pattern (use % for wildcards, V$ prefix optional)
SELECT on V$FIXED_VIEW_DEFINITION
Fixed View Definitions
VIEW NAME VIEW DEFINITION
------------------------------ --------------------------------------------------------------------------------
V$SESSION select s.indx, s.ksuseser, s.ksusetid, s.ksusepid, s.ksusepnm, s.ksuseunm,
s.ksusemnm, s.ksuseapp, s.ksuseclid, s.ksuseser, s.ksuseopc, s.ksuseblocker,
s.ksuudlna, s.ksuudoct, s.ksusesql, s.ksusesqh, s.ksusesch, s.ksuseflg,
s.ksusepsi, s.ksuseti, s.ksusesoi from x$ksuse s where bitand(s.ksspaflg,1)!=0
and bitand(s.ksuseflg,1)!=0
V$SESSTAT select s.indx,s.ksuseser,n.indx,s.ksusestn from x$ksuse s, x$ksusestat u,
x$ksusd n where bitand(s.ksspaflg,1)!=0 and bitand(s.ksuseflg,1)!=0 and
u.ksuudsui = s.indx and u.ksuudste = n.indx and n.ksusdste != 0
V$SQL select sql_text, sql_fulltext, sql_id, sharable_mem, persistent_mem,
runtime_mem, sorts, loaded_versions, open_versions, users_opening,
fetches, executions, px_servers_executions, end_of_fetch_count, users_executing,
loads, first_load_time, invalidations, parse_calls, disk_reads, direct_writes,
buffer_gets, application_wait_time, concurrency_wait_time, cluster_wait_time,
user_io_wait_time, plsql_exec_time, java_exec_time, rows_processed, command_type,
optimizer_mode, optimizer_cost, optimizer_env, optimizer_env_hash_value,
parsing_user_id, parsing_schema_id, parsing_schema_name, kept_versions,
address, type_chk_heap, hash_value, old_hash_value, plan_hash_value,
child_number, service, service_hash, module, module_hash, action, action_hash,
serializable_aborts, outline_category, cpu_time, elapsed_time, outline_sid,
child_address, sqltype, remote, object_status, literal_hash_value,
last_load_time, is_obsolete, is_bind_sensitive, is_bind_aware, is_shareable,
child_latch, sql_profile, sql_patch, sql_plan_baseline, program_id, program_line#,
exact_matching_signature, force_matching_signature, last_active_time,
bind_data, typecheck_mem from v$sql_shared_cursor s where s.kglhdpar = s.kglhdadr
-- Fixed views are built on X$ tables:
-- X$KSUSE: Session information (basis for V$SESSION)
-- X$KSUSESTAT: Session statistics (basis for V$SESSTAT)
-- X$KGLCURSOR: SQL cursors (basis for V$SQL)
-- X$KCBFWAIT: Buffer waits (basis for V$WAITSTAT)
-- Common construction patterns:
-- Direct mapping from X$ tables
-- Joins between multiple X$ tables
-- Filtering with WHERE clauses
-- Data transformation and decoding
-- Aggregation and summarization
-- Insights gained:
-- How Oracle organizes internal data
-- Relationships between internal structures
-- Filtering logic for exposed data
-- Performance implications of view access
-- Performance view construction:
-- How statistics are collected and aggregated
-- Why certain views may be expensive to query
-- Relationships between different monitoring views
-- Impact of view complexity on query performance
  1. Oracle Education and Learning

    • Understand Oracle’s internal architecture
    • Learn how monitoring views are constructed
    • Study Oracle’s data organization
    • Support Oracle certification and training
  2. Performance Analysis

    • Understand view query costs
    • Optimize monitoring query performance
    • Design efficient monitoring solutions
    • Troubleshoot view-related performance issues
  3. Custom Monitoring Development

    • Design custom monitoring views
    • Understand data source relationships
    • Optimize monitoring query design
    • Create efficient monitoring solutions
  4. Troubleshooting

    • Understand view behavior and limitations
    • Investigate monitoring data discrepancies
    • Support Oracle support interactions
    • Debug monitoring applications
-- View complexity indicators:
-- Number of base tables joined
-- Complexity of WHERE clauses
-- Presence of functions and calculations
-- Aggregation operations
-- Cost factors:
-- Complex joins increase cost
-- Filtering conditions affect performance
-- Large X$ tables require more resources
-- Multiple table access patterns
-- Common relationship patterns:
-- Parent-child relationships via index columns
-- Many-to-many relationships through junction tables
-- Hierarchical relationships in nested structures
-- Time-based relationships for historical data
-- Understanding data flow:
-- How data moves from kernel to X$ tables
-- When X$ table data is updated
-- Relationship between V$ views and GV$ views
-- Impact of database activity on view data
-- Optimize monitoring queries by:
-- Understanding view join patterns
-- Adding appropriate WHERE clauses
-- Avoiding expensive view columns
-- Using more efficient alternative views
-- Develop custom views using:
-- Similar patterns to Oracle views
-- Efficient join strategies
-- Appropriate filtering logic
-- Performance-conscious design
-- Learn Oracle architecture through:
-- View definition analysis
-- X$ table structure understanding
-- Internal relationship mapping
-- Performance characteristic study
-- Support training with:
-- Real Oracle implementation examples
-- Internal structure documentation
-- Performance impact education
-- Best practice development
-- Session view pattern:
-- Base table: X$KSUSE (session info)
-- Filtering: Active sessions only
-- Additional joins: For extended information
-- Performance: Moderate cost
-- Statistics view pattern:
-- Base tables: X$KSUSE + X$KSUSESTAT + X$KSUSD
-- Joins: Session to statistics to names
-- Filtering: Active sessions and valid statistics
-- Performance: Higher cost due to joins
-- SQL view pattern:
-- Base table: X$KGLCURSOR (shared cursors)
-- Complexity: High due to cursor management
-- Filtering: Various cursor states and types
-- Performance: Can be expensive for large cursor caches
-- Systematic learning:
-- Start with simple views (V$DATABASE, V$INSTANCE)
-- Progress to more complex views (V$SESSION, V$SQL)
-- Study view relationships and dependencies
-- Practice with different view patterns
-- Create documentation:
-- Document interesting view patterns
-- Note performance characteristics
-- Create reference materials for teams
-- Share learning with colleagues
-- Design principles:
-- Follow Oracle's established patterns
-- Implement efficient filtering
-- Consider performance implications
-- Test thoroughly before deployment
-- Performance guidelines:
-- Understand view costs before using
-- Add appropriate WHERE clauses
-- Avoid unnecessary complex views
-- Monitor query performance impact
-- Analyze specific view:
Enter value for view: V$SESSION
-- Find SQL-related views:
Enter value for view: %SQL%
-- Find session-related views:
Enter value for view: %SESS%
-- Find lock-related views:
Enter value for view: %LOCK%
-- List all fixed views:
Enter value for view: %
-- Find performance-related views:
Enter value for view: %STAT%
Enter value for view: %WAIT%
Enter value for view: %EVENT%
-- Security considerations:
-- View definitions reveal internal architecture
-- X$ table names and structures exposed
-- Potential security implications
-- Limit access to appropriate personnel
-- Usage guidelines:
-- Primarily educational and development tool
-- Use in development and test environments
-- Consider security implications in production
-- Implement appropriate access controls
-- Development applications:
-- Understand data sources for monitoring apps
-- Design efficient monitoring queries
-- Create custom performance views
-- Optimize monitoring application performance
-- Support case improvements:
-- Better understanding of Oracle internals
-- More informed discussions with Oracle Support
-- Enhanced troubleshooting capabilities
-- Improved problem description accuracy

This script is essential for:

  1. Oracle Education - Understanding Oracle’s internal architecture and fixed view construction
  2. Performance Analysis - Understanding view costs and optimizing monitoring queries
  3. Custom Development - Supporting efficient custom monitoring view development
  4. Troubleshooting - Understanding view behavior and resolving monitoring issues
  5. Architecture Learning - Gaining deep insight into Oracle’s internal data organization and relationships