1. 查看数据库的当前状态(是否打开、是否可读写等):```sqlSELECT status FROM v$instance;```
2. 查看数据库的归档模式(ARCHIVELOG 或 NOARCHIVELOG):```sqlSELECT log_mode FROM v$database;```
3. 查看数据库的实例名和数据库域名:```sqlSELECT instance_name, db_domain FROM v$instance;```
4. 查看数据库的版本信息:```sqlSELECT banner FROM v$version;```
5. 查看数据库的当前时间:```sqlSELECT TO_CHAR FROM DUAL;```
6. 查看数据库的当前用户:```sqlSELECT user FROM dual;```
7. 查看数据库的表空间使用情况:```sqlSELECT tablespace_name, status, contents FROM dba_tablespaces;```
8. 查看数据库的临时表空间使用情况:```sqlSELECT tablespace_name, status FROM dba_tablespaces WHERE contents = 'TEMPORARY';```
9. 查看数据库的参数设置:```sqlSELECT name, value FROM v$parameter;```
10. 查看数据库的SGA和PGA设置:```sqlSELECT name, value FROM v$sga;SELECT name, value FROM v$pga_target_advice;```
11. 查看数据库的当前会话:```sqlSELECT sid, serial, username, program, machine FROM v$session;```
12. 查看数据库的等待事件:```sqlSELECT event, total_waits, time_waited FROM v$system_event;```
13. 查看数据库的锁信息:```sqlSELECT l.session_id, l.locked_mode, l.oracle_username, l.os_user_name, s.machine, s.program, o.object_name, o.object_typeFROM v$locked_object l, dba_objects o, v$session sWHERE l.object_id = o.object_id AND l.session_id = s.sid;```
14. 查看数据库的归档日志信息:```sqlSELECT name, value FROM v$parameter WHERE name LIKE 'log_archive_dest%';```
15. 查看数据库的备份信息:```sqlSELECT session_key, status, input_type, output_type, input_bytes, output_bytesFROM v$rman_backup_job_details;```
16. 查看数据库的统计信息:```sqlSELECT name, value FROM v$sysstat;```
17. 查看数据库的AWR报告:```sqlSELECT dbid, instance_number, snap_id, begin_interval_time, end_interval_timeFROM dba_hist_snapshot;```
18. 查看数据库的EM Express报告:```sqlSELECT name, value FROM v$em_feature_usage_statistics;```
19. 查看数据库的ADDM报告:```sqlSELECT name, value FROM v$addm_task;```
20. 查看数据库的ASH报告:```sqlSELECT sample_time, session_id, session_serial, username, program, machine, sql_id, sql_plan_hash_value, event, wait_class, time_waitedFROM v$active_session_history;```
21. 查看数据库的SQL性能分析报告:```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM v$sql;```
22. 查看数据库的SQL执行计划:```sqlSELECT FROM tableqwe2;```
23. 查看数据库的SQL优化器统计信息:```sqlSELECT name, value FROM v$sys_optimizer_env;```
24. 查看数据库的SQL执行历史:```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sqlstat;```
25. 查看数据库的SQL执行计划历史:```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan;```
26. 查看数据库的SQL执行计划历史(按SQL_ID):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id';```
27. 查看数据库的SQL执行计划历史(按SQL_ID和PLAN_HASH_VALUE):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id' AND plan_hash_value = 'your_plan_hash_value';```
28. 查看数据库的SQL执行计划历史(按SQL_ID和PLAN_HASH_VALUE,按时间排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id' AND plan_hash_value = 'your_plan_hash_value'ORDER BY begin_interval_time;```
29. 查看数据库的SQL执行计划历史(按SQL_ID,按时间排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY begin_interval_time;```
30. 查看数据库的SQL执行计划历史(按SQL_ID,按执行次数排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY executions DESC;```
31. 查看数据库的SQL执行计划历史(按SQL_ID,按CPU时间排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY cpu_time DESC;```
32. 查看数据库的SQL执行计划历史(按SQL_ID,按磁盘读取次数排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY disk_reads DESC;```
33. 查看数据库的SQL执行计划历史(按SQL_ID,按逻辑读取次数排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY buffer_gets DESC;```
34. 查看数据库的SQL执行计划历史(按SQL_ID,按行处理次数排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY rows_processed DESC;```
35. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time DESC;```
36. 查看数据库的SQL执行计划历史(按SQL_ID,按CPU时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY cpu_time / executions DESC;```
37. 查看数据库的SQL执行计划历史(按SQL_ID,按磁盘读取时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY disk_reads / executions DESC;```
38. 查看数据库的SQL执行计划历史(按SQL_ID,按逻辑读取时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY buffer_gets / executions DESC;```
39. 查看数据库的SQL执行计划历史(按SQL_ID,按行处理时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY rows_processed / executions DESC;```
40. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC;```
41. 查看数据库的SQL执行计划历史(按SQL_ID,按CPU时间占比排序,按执行次数排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY cpu_time / executions DESC, executions DESC;```
42. 查看数据库的SQL执行计划历史(按SQL_ID,按磁盘读取时间占比排序,按执行次数排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY disk_reads / executions DESC, executions DESC;```
43. 查看数据库的SQL执行计划历史(按SQL_ID,按逻辑读取时间占比排序,按执行次数排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY buffer_gets / executions DESC, executions DESC;```
44. 查看数据库的SQL执行计划历史(按SQL_ID,按行处理时间占比排序,按执行次数排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY rows_processed / executions DESC, executions DESC;```
45. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按执行次数排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, executions DESC;```
46. 查看数据库的SQL执行计划历史(按SQL_ID,按CPU时间占比排序,按磁盘读取次数排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY cpu_time / executions DESC, disk_reads DESC;```
47. 查看数据库的SQL执行计划历史(按SQL_ID,按磁盘读取时间占比排序,按逻辑读取次数排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY disk_reads / executions DESC, buffer_gets DESC;```
48. 查看数据库的SQL执行计划历史(按SQL_ID,按逻辑读取时间占比排序,按行处理次数排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY buffer_gets / executions DESC, rows_processed DESC;```
49. 查看数据库的SQL执行计划历史(按SQL_ID,按行处理时间占比排序,按执行时间排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY rows_processed / executions DESC, elapsed_time DESC;```
50. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按CPU时间排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, cpu_time DESC;```
51. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按磁盘读取次数排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, disk_reads DESC;```
52. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按逻辑读取次数排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, buffer_gets DESC;```
53. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理次数排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed DESC;```
54. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按磁盘读取时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, disk_reads / executions DESC;```
55. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按逻辑读取时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, buffer_gets / executions DESC;```
56. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC;```
57. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按CPU时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, cpu_time / executions DESC;```
58. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按磁盘读取时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, disk_reads / executions DESC;```
59. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按逻辑读取时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, buffer_gets / executions DESC;```
60. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC;```
61. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按CPU时间占比排序,按执行次数排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, cpu_time / executions DESC, executions DESC;```
62. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按磁盘读取时间占比排序,按执行次数排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, disk_reads / executions DESC, executions DESC;```
63. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按逻辑读取时间占比排序,按执行次数排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE64. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按执行次数排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, executions DESC;```
65. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按CPU时间占比排序,按磁盘读取次数排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, cpu_time / executions DESC, disk_reads DESC;```
66. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按磁盘读取时间占比排序,按逻辑读取次数排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, disk_reads / executions DESC, buffer_gets DESC;```
67. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按逻辑读取时间占比排序,按行处理次数排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, buffer_gets / executions DESC, rows_processed DESC;```
68. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按CPU时间排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, cpu_time DESC;```
69. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按磁盘读取次数排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, disk_reads DESC;```
70. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按逻辑读取次数排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, buffer_gets DESC;```
71. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按磁盘读取时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, disk_reads / executions DESC;```
72. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按逻辑读取时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, buffer_gets / executions DESC;```
73. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按行处理时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, rows_processed / executions DESC;```
74. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按CPU时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, cpu_time / executions DESC;```
75. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按磁盘读取时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, disk_reads / executions DESC;```
76. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按逻辑读取时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, buffer_gets / executions DESC;```
77. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按行处理时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, rows_processed / executions DESC;```
78. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按CPU时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, cpu_time / executions DESC;```
79. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按磁盘读取时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, disk_reads / executions DESC;```
80. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按逻辑读取时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, buffer_gets / executions DESC;```
81. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按行处理时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, rows_processed / executions DESC;```
82. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按CPU时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, cpu_time / executions DESC;```
83. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按磁盘读取时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, disk_reads / executions DESC;```
84. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按逻辑读取时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, buffer_gets / executions DESC;```
85. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按行处理时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, rows_processed / executions DESC;```
86. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按CPU时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, cpu_time / executions DESC;```
87. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按磁盘读取时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, disk_reads / executions DESC;```
88. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按逻辑读取时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, buffer_gets / executions DESC;```
89. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按行处理时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, rows_processed / executions DESC;```
90. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按CPU时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, cpu_time / executions DESC;```
91. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按磁盘读取时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, disk_reads / executions DESC;```
92. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按逻辑读取时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, buffer_gets / executions DESC;```
93. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按行处理时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, rows_processed / executions DESC;```
94. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按CPU时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, cpu_time / executions DESC;```
95. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按磁盘读取时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, disk_reads / executions DESC;```
96. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按逻辑读取时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, buffer_gets / executions DESC;```
97. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按行处理时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, rows_processed / executions DESC;```
98. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按CPU时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, cpu_time / executions DESC;```
99. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按磁盘读取时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, disk_reads / executions DESC;```
100. 查看数据库的SQL执行计划历史(按SQL_ID,按执行时间占比排序,按行处理时间占比排序,按逻辑读取时间占比排序):```sqlSELECT sql_id, plan_hash_value, executions, elapsed_time, cpu_time, buffer_gets, disk_reads, rows_processedFROM dba_hist_sql_plan WHERE sql_id = 'your_sql_id'ORDER BY elapsed_time / executions DESC, rows_processed / executions DESC, buffer_gets / executions DESC;```
这些查询可以帮助你了解Oracle数据库的各个方面,包括状态、配置、性能和执行历史。如果你有特定的需求或问题,可以进一步查询相关的数据字典视图或使用其他Oracle提供的工具和报告。
Oracle数据库状态查看详解
Oracle数据库是广泛使用的关系型数据库管理系统,其稳定性和可靠性得到了全球用户的认可。在日常运维过程中,了解和查看数据库状态是保证数据库正常运行的重要环节。本文将详细介绍如何查看Oracle数据库的状态。
一、数据库状态概述
Oracle数据库状态主要包括以下几种:
NOMOUNT:数据库实例启动,但尚未加载控制文件和数据文件。
MOUNT:数据库实例加载了控制文件和数据文件,但尚未打开数据库。
OPEN:数据库实例已打开,用户可以访问数据库。
二、查看数据库状态的方法
以下介绍几种常用的方法来查看Oracle数据库的状态:
1. 使用SQLPlus工具
SQLPlus是Oracle提供的一个命令行工具,可以方便地执行SQL语句和PL/SQL代码。以下是如何使用SQLPlus查看数据库状态的步骤:
打开SQLPlus,输入用户名和密码连接到数据库。
执行以下SQL语句查看数据库状态:
SELECT status FROM v$instance;
根据返回的结果判断数据库状态。
2. 使用Oracle Enterprise Manager (OEM)
Oracle Enterprise Manager是Oracle提供的一个图形化界面工具,可以方便地管理数据库。以下是如何使用OEM查看数据库状态的步骤:
打开OEM控制台。
在导航树中选择“Database”。
在右侧窗格中,选择要查看状态的数据库。
在“General”选项卡中,可以查看数据库的当前状态。
3. 使用SQL查询
除了使用SQLPlus和OEM,还可以通过编写SQL查询来查看数据库状态。以下是一个示例查询:
连接到数据库。
执行以下SQL查询:
SELECT instance_name, status FROM v$instance;
根据返回的结果判断数据库状态。
三、数据库状态切换
在数据库运维过程中,可能需要根据实际情况切换数据库状态。以下是如何切换数据库状态的步骤:
1. 从NOMOUNT状态切换到MOUNT状态
使用SQLPlus连接到数据库。
执行以下命令:
ALTER DATABASE MOUNT;
2. 从MOUNT状态切换到OPEN状态
使用SQLPlus连接到数据库。
执行以下命令:
ALTER DATABASE OPEN;
3. 从OPEN状态切换到MOUNT状态
使用SQLPlus连接到数据库。
执行以下命令:
SHUTDOWN IMMEDIATE;
然后执行以下命令将数据库状态切换到MOUNT:
ALTER DATABASE MOUNT;
了解和查看Oracle数据库状态是数据库运维的重要环节。本文介绍了使用SQLPlus、OEM和SQL查询等方法查看数据库状态,以及如何切换数据库状态。掌握这些方法有助于确保数据库的稳定运行。