|
autotrace脚本所在的位置:
- /u01/app/oracle/product/12.1.0/dbhome_1/sqlplus/admin
复制代码- [oracle@station90 admin]$ sqlplus /nolog
- SQL*Plus: Release 12.1.0.2.0 Production on Sat Sep 1 09:42:10 2018
- Copyright (c) 1982, 2014, Oracle. All rights reserved.
- SQL> conn / as sysdba
- Connected.
- SQL> @plustrce.sql
- SQL>
- SQL> drop role plustrace;
- drop role plustrace
- *
- ERROR at line 1:
- ORA-01919: role 'PLUSTRACE' does not exist
- SQL> create role plustrace;
- Role created.
- SQL>
- SQL> grant select on v_$sesstat to plustrace;
- Grant succeeded.
- SQL> grant select on v_$statname to plustrace;
- Grant succeeded.
- SQL> grant select on v_$mystat to plustrace;
- Grant succeeded.
- SQL> grant plustrace to dba with admin option;
- Grant succeeded.
- SQL>
- SQL> set echo off
- SQL> grant plustrace to hr;
- Grant succeeded.
- SQL>
复制代码- SQL> conn hr/oracle_4U
- Connected.
- SQL> set autot traceonly explain
- SQL> set autot traceonly statistics
- SQL> set autot on
- SQL> set autot traceonly
- SQL>
复制代码
- select * from dba_outstanding_alerts;
-
- ---WR_[ DISCUZ_CODE_7 ]nbsp; I M R H SYSAUX SYS
-
- select * from dba_views v
- where v.VIEW_NAME='DBA_OUTSTANDING_ALERTS';
-
- select * from dba_views v
- where v.VIEW_NAME= 'INT$DBA_OUTSTANDING_ALERTS';
-
- ----WRI$_ALERT_OUTSTANDING
- select * from dba_tables t where t.table_name='WRI$_ALERT_OUTSTANDING';
复制代码 | OWNER | TABLE_NAME | TABLESPACE_NAME | CLUSTER_NAME | IOT_NAME | STATUS | PCT_FREE | PCT_USED | INI_TRANS | MAX_TRANS | INITIAL_EXTENT | NEXT_EXTENT | MIN_EXTENTS | MAX_EXTENTS | PCT_INCREASE | FREELISTS | FREELIST_GROUPS | LOGGING | BACKED_UP | NUM_ROWS | BLOCKS | EMPTY_BLOCKS | AVG_SPACE | CHAIN_CNT | AVG_ROW_LEN | AVG_SPACE_FREELIST_BLOCKS | NUM_FREELIST_BLOCKS | DEGREE | INSTANCES | CACHE | TABLE_LOCK | SAMPLE_SIZE | LAST_ANALYZED | PARTITIONED | IOT_TYPE | TEMPORARY | SECONDARY | NESTED | BUFFER_POOL | FLASH_CACHE | CELL_FLASH_CACHE | ROW_MOVEMENT | GLOBAL_STATS | USER_STATS | DURATION | SKIP_CORRUPT | MONITORING | CLUSTER_OWNER | DEPENDENCIES | COMPRESSION | COMPRESS_FOR | DROPPED | READ_ONLY | SEGMENT_CREATED | RESULT_CACHE | CLUSTERING | ACTIVITY_TRACKING | DML_TIMESTAMP | HAS_IDENTITY | CONTAINER_DATA | INMEMORY | INMEMORY_PRIORITY | INMEMORY_DISTRIBUTE | INMEMORY_COMPRESSION | INMEMORY_DUPLICATE | 1 | SYS | WRI$_ALERT_OUTSTANDING | SYSAUX | | | VALID | 10 | | 1 | 255 | 65536 | 1048576 | 1 | 2147483645 | | | | YES | N | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | N | ENABLED | 0 | 1/20/2018 5:53:03 PM | NO | | N | N | NO | DEFAULT | DEFAULT | DEFAULT | DISABLED | YES | NO | | DISABLED | YES | | DISABLED | DISABLED | | NO | NO | YES | DEFAULT | NO | | | NO | NO | DISABLED | | | | |
- select * from dba_alert_history ah
- order by ah.TIME_SUGGESTED desc;
-
- select * from dba_views v
- where v.VIEW_NAME='DBA_ALERT_HISTORY';
-
- select * from dba_views v
- where v.VIEW_NAME= 'INT$DBA_ALERT_HISTORY';
-
- ----WRI$_ALERT_HISTORY
- select * from dba_tables t where t.table_name='WRI$_ALERT_HISTORY';
- select substr(t.table_name,3,1), count(*)
- from dba_tables t
- where t.owner='SYS' and t.tablespace_name='SYSAUX' and
- t.table_name like 'WR_$%'
- group by substr(t.table_name,3,1);
- select t.table_name from dba_tables t
- where t.owner='SYS' and t.tablespace_name='SYSAUX' and
- t.table_name like 'WRH$%';
-
- select * from WRH$_MEMORY_RESIZE_OPS;
-
- select * from v$MEMORY_RESIZE_OPS;
-
复制代码- begin
- dbms_stats.gather_table_stats('HR','T04209_UNAME');
- end;
-
- select t.num_rows ,t.last_analyzed from dba_tables t
- where t.owner='HR' and t.table_name='T04209_UNAME';
-
- select * from dba_tab_col_statistics tcs
- where tcs.owner='HR' and tcs.table_name='T04209_UNAME';
-
- begin
- dbms_stats.gather_table_stats('HR','T04209_UNAME',
- estimate_percent => 100,
- method_opt => 'for all columns size auto for columns uvalue size 101'
- );
- end;
-
- select * from dba_tab_col_statistics tcs
- where tcs.owner='HR' and tcs.table_name='T04209_UNAME';
-
- select * from dba_histograms h
- where h.owner='HR' and h.table_name='T04209_UNAME'
- and h.column_name='UVALUE';
复制代码- select dbms_stats.get_prefs (pname => 'STALE_PERCENT') from dual;
- begin
- dbms_stats.set_table_prefs('HR','T04209_UNAME','STALE_PERCENT','13');
- end;
- select dbms_stats.get_prefs (pname => 'STALE_PERCENT',
- ownname => 'HR' , tabname => 'T04209_UNAME') from dual;
复制代码
KEEP:
- create tablespace tbs16k datafile size 5M blocksize 16384;
- alter system set db_16k_cache_size=10M;
- alter system set db_keep_cache_size=10M;
- select t.buffer_pool from dba_tables t where t.owner='HR' and t.table_name='EMPLOYEES';
- alter table hr.employees storage ( buffer_pool keep);
- begin
- dbms_shared_pool.keep('HR.SECURE_DML');
- end;
-
- select c.NAME, c.KEPT from v_$db_object_cache c
- where c.OWNER='HR';
复制代码
cursor_sharing=similar:
---------------------------------
发布与否优化器统计信息:
- select s.SQL_ID, s.SQL_HASH_VALUE from v_$session s
- where terminal='pts/10';
-
- select sql_text from v$sql where sql_id='dh73w3ss300hp';
-
- begin
- dbms_stats.set_table_prefs('HR','EMPLOYEES',pname => 'PUBLISH',pvalue => 'FALSE');
- end;
-
- select * from dba_tab_pending_stats;
-
- begin
- dbms_stats.gather_table_stats('HR','EMPLOYEES');
- end;
-
- begin
- dbms_stats.publish_pending_stats(ownname => 'HR',tabname => 'EMPLOYEES');
- end;
复制代码 看懂AWR的前提是看懂以下两个视图:
- select * from v$system_wait_class;
- select * from v$event_name;
复制代码
|
-
|