Flushing caches for testing:
- ALTER SYSTEM FLUSH BUFFER_CACHE;
- alter system flush shared_pool;
Finding unusable, invalid, and disabled indexes:
- select owner, index_name from dba_indexes where status='UNUSABLE';
- select index_name, status from dba_indexes where status = 'DISABLED';
- select owner,table_name,index_name,last_analyzed,status from dba_indexes where status != 'VALID';
Rebuild index:
- alter index XXX.XXX rebuild;
Compute schema statistics:
- exec DBMS_UTILITY.ANALYZE_SCHEMA('schemaName','COMPUTE');
Hints to pin/unpin data in buffer cache:
- alter table XXX storage (buffer_pool keep);
- alter index XXX storage (buffer_pool keep);
- alter table XXX storage (buffer_pool default);
- alter index XXX storage (buffer_pool default);
Recently executed queries:
- SELECT a.USERNAME, b.sql_text, a.STATUS FROM V$SESSION a INNER JOIN V$SQLAREA b ON a.SQL_ID = b.SQL_ID;
- select sql_text from v$sqlarea where sql_text like '%someText%' order by last_active_time desc;
SQL datapump importing/exporting
Oracle 11g R2 (11.2) sequence numbers skip
Note on Using Sequences with Deferred Segments If you attempt to insert a sequence value into a table that uses deferred segment creation, the first value that the sequence returns will be skipped.
The solution is to run “alter system set deferred_segment_creation=false;” as system user. This setting is a one-time thing for a database install.
Out or disk space:
While running high volume and performance tests, Oracle keeps consuming all available disk space. Discovered it was the undo and temp tablespaces. The following statements recover the space.
ALTER DATABASE DATAFILE '/oracle_ee/app/oradata/orcl/undotbs01.dbf' RESIZE 200m;
ALTER TABLESPACE temp SHRINK SPACE KEEP 256M;
Moving temp and undo tablespaces:
select * from dba_tablespaces;
select * from dba_data_files;
CREATE TEMPORARY TABLESPACE temp2 TEMPFILE '/media/oradata/temp2_01.dbf'
SIZE 100M REUSE AUTOEXTEND ON MAXSIZE unlimited EXTENT MANAGEMENT LOCAL UNIFORM SIZE 64K;
ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp2;
DROP TABLESPACE temp INCLUDING CONTENTS AND DATAFILES;
create undo tablespace undotbs2 datafile '/media/oradata/undo02.dbf' size 2000m AUTOEXTEND ON MAXSIZE unlimited EXTENT MANAGEMENT LOCAL;
alter system set undo_tablespace= undotbs2 ;
drop tablespace undotbs1 including contents and datafiles;