Query Recycle Bin content, greater than - you need to clean up
SELECT count (1) from Dba_recyclebin;
Clean up all contents of the Recycle Bin
Purge Dba_recyclebin;
Querying all Table spaces
SELECT ' result= ' | | Df.tablespace_name "Tablespace", df.bytes/(1024x768*1024x768) "Total Size (MB)",
SUM (fs.bytes)/(1024x768*1024x768) "Free Size (MB)", Round (SUM (fs.bytes) *+/df.bytes) "% free",
Round ((Df.bytes-sum (fs.bytes)) */df.bytes) "% used"
From (Selecta.bytes,a.tablespace_name to Dba_free_spacea UNION all SELECT b.bytes_free,b.tablespace_name from V$TEMP_ Space_header b) FS,
(select Tablespace_name, sum (bytes) bytes from Dba_data_files GROUP by Tablespace_name UNION all SELECT tablespace_name, SUM (bytes) Total from Dba_temp_files GROUP by Tablespace_name DF
WHERE Fs.tablespace_name = Df.tablespace_name
GROUP by Df.tablespace_name, Df.bytes;
Query who occupies a table space
SELECT * FROM
(SELECT owner,segment_name, sum (bytes)/1024x768/1024x768 Mbytese from Dba_segments WHERE tablespace_name in ( ' Cbs_default_dat ')
GROUP by Owner,segment_name ORDER by Mbytese DESC)
WHERE rownum<=Ten;
Statistical Information Timing task is normal, the number of results is greater than 0 it indicates normal
SELECT count (1) from Dba_autotask_job_history a WHERE a.client_name= ' auto Optimizer stats collection ' and Jo B_status= ' succeeded ' and A.window_start_time >=sysdate-2;
Check SQL whether the variable is bound
Selectsubstr (Sql_text, 1, +) "SQL", count (*),
SUM (executions) "Totexecs"
From V$sqlarea
WHERE Executions < 5
GROUP bysubstr (Sql_text, 1, +)
Having count (*) >
ORDER by 2 DESC;
SQL return query time more than 5 seconds of SQL
SELECT P.spid, S.sid,s.last_call_et,
S.machine, S.program, S.terminal,
W.event,q.sql_text
From V$process p,
V$session S,
V$sqltext Q,
V$session_wait W
WHERE p.addr = s.paddr
and s.sql_address = q.address
and s.status = ' ACTIVE '
and P.background is NULL
and S.sid = W.sid
and S.last_call_et > 5
ORDER by S.last_call_et DESC, S.sid, q.piece;
Check that the partitioned table has a global index and if the query returns a record, the global index is established and needs to be re-established as a local index or a global partition index
SELECT A.owner, A.table_name, a.index_name,a.partitioned, A.status
From Dba_indexes A, dba_part_tables b
WHERE A.table_name = B.table_name
and A.owner not in (' SYS ', ' SYSTEM ')
and a.partitioned <> ' YES ';
Check business object parallelism settings
SELECT owner, object_name, degree
From (SELECT a.owner,a.table_name object_name, A.degree
From Dba_tables A
WHERE trim (a.degree) > ' 1 '
UNION All
SELECT A.owner, A.index_name object_name, A.degree
From Dba_indexes A
WHERE trim (a.degree) > ' 1 '
) b
WHERE B.owner not in (' SYS ', ' SYSTEM ', ' Sysman ', ' Mgmt_view ')
and B.owner not in (SELECT c.username from dba_users_with_defpwd c);
Set index parallelism to 1
ALTER INDEX idx_name Noparallel;
Set table parallelism to 1
ALTER TABLE table_name Noparallel;
Check for non-normal Job
Selectjob,schema_user,what from Dba_jobs WHERE broken= ' Y ';
Fix Job: Check Oracle Alarm log, Analysis Job the cause of the failure. after the corresponding job number is found ( for example ), use the following command to Broken change to N
Execdbms_job.broken (false);
Check for the existence of a failed object
SELECT T.owner,t.object_type,
T.object_name, T.status
From Dba_objects t
WHERE t.status = ' INVALID '
--If it doesn't work, it is recommended to delete.
--if useful, recompile is required.
--Re-compiling objects
ALTER object_type Object_owner.object_name compile;
--Re-compiling the user
Execute Dbms_utility.compile_schema (schema = ", Compile_all = False);
--Recompile the database
@?/rdbms/admin/utlrp.sql
Create an index online
CREATE INDEX index_name on table_name (col_name) tablespace tablespace_nameonline;
creating indexes in parallel ( If you are creating online, please remove the offline parameters )
CREATE INDEX index_name on table_name (col_name) Parallel 4 tablespace tablespace_name online;
ALTER INDEX index_name Noparallel;
Rebuilding indexes Online
EXPDP sysdb/sys_db1 dumpfile=sysdb_expdb20120415.dmp directory=dpump_dir logfile=sysdb.log EXCLUDE=TABLE:\ "IN\ (\ ') Mdsp_cdr\ ', \ ' t_bme_taskrunresult\ ', \ ' tb_interactlog\ ' \) \ "
Export data exclude some tables
EXPDP sysdb/sys_db1 dumpfile=sysdb_expdb20120415.dmp directory=dpump_dir logfile=sysdb.log EXCLUDE=TABLE:\ "IN\ (\ ') Mdsp_cdr\ ', \ ' t_bme_taskrunresult\ ', \ ' tb_interactlog\ ' \) \ ";
Single-table import and export
EXPDP sysdb/sysdb tables=tb1 directory= dpump_dir dumpfile=sysdb_tb_mobileno.dmp
IMPDP sysdb/sysdb t directory=dpump_dir dumpfile= dumpfile=sysdb_tb_mobileno.dmp tables= TB1;
Recovering table data from different users
EXPDP sysdb/sys_db1 Directory=dmpdir Content=all dumpfile=tcategory_relation.dmptables=tcategory_relation
IMPDP sysdb5/sys_db1 directory=dmpdir dumpfile=tcategory_relation.dmp tables=tcategory_relation remap_schema=sysdb: SYSDB5;
To transfer table space to a table, you need to stop the business operation, and the index will be rebuilt after the table is rebuilt
ALTER TABLE table_name Move tablespace <new tablespace>;
ALTER INDEX index_name rebuild online;
Transfer table space to an index
ALTER INDEX pk_mdsp_t_rentinfo_2 rebuild Onlinetablespace ts_mdsp_idx;
Lower the High water level
ALTER TABLE table_name enable row movement;
ALTER TABLE table_name shrink Space Compact;
ALTER TABLE table_name shrink space cascade;
Collecting statistics for a table
EXEC dbms_stats.gather_table_stats (ownname=> ' uppercase database user name ',tabname=> ' uppercase table name ',degree=>4, cascade= >true,force=>true,no_invalidate=>false);
Collect statistics for users
EXEC dbms_stats.gather_schema_stats (ownname=> ' capitalized database user name ', estimate_percent = dbms_stats. Auto_sample_size,degree=>4, cascade=>true,force=>true,no_invalidate=>false);
How to check for invalid indexes
SELECT A.owner, A.index_name,a.status
From Dba_indexes A
WHERE a.status = ' unusable '
UNION All
SELECT A.index_owner, A.index_name, A.status
From Dba_ind_partitions A
WHERE a.status = ' unusable ';
Check for invalid indexes and display rebuild statements
SELECT ' alter index ' | | a.owner| | '. ' | | A.index_name | | ' Rebuild online; ' As Rebuild_index_sql
From Dba_indexes A
WHERE a.partitioned <> ' YES '
and (A.status = ' unusable ')
UNION
SELECT ' alter index ' | | t.index_owner| | '. ' | | T.index_name | | ' Rebuildpartition ' | |
T.partition_name | | ' Online; ' As Rebuild_index_sql
From Dba_ind_partitions t,user_part_indexes n
WHERE (t.status = ' unusable ');
How to recover deleted data , if the data is mistakenly deleted and the time is not very long, you can undo table space Restores the table data, please modify the indication and time for the field
CREATE TABLE table_name_new as SELECT * FROM table_name as of timestamp to_timestamp (' 2013-03-2611:00:00 ', ' Yyyy-mm-dd HH 24:mi:ss ');
Create Snapshot
Executedbms_workload_repository.create_snapshot;
Collect AWR Report
@?/rdbms/admin/awrrpt.sql
Collect ASH Report
@?/rdbms/admin/ashrpt.sql
Enquiry Session Historical Information
SELECT *
From Dba_hist_active_sess_history t
WHERE t.sample_time > To_date (' 20130811 070000 ', ' yyyymmdd Hh24miss ')
and T.sample_time < To_date (' 20130811 090000 ', ' Yyyymmddhh24miss ');
Check Transaction lock
SELECT ' Session ' | | C.locker | |
' Lock Session ' | | C.locked
As "result"
From (SELECT a.sid locked,
B.sid Locker
From V$lock A, V$lock b
WHERE a.request >0
and A.ID1 = B.id1
and A.id2 = B.id2
and A.type = B.type
and A.addr <> b.addr
C
V$session D
WHERE c.locker = D.sid;
Check the lock and display the KILL lock statement
SELECT DISTINCT ' kill-9 ' | |
P.spid | | ‘;‘ As "result"
From (SELECT a.sid locked,
B.sid Locker
From V$lock A, V$lock b
WHERE a.request >0
and A.ID1 = B.id1
and A.id2 = B.id2
and A.type = B.type
and A.addr <> b.addr
C
V$session D,
V$process P
WHERE C.locker = D.sid and d.paddr=p.addr;
Clean up archive log operations
--Method One
Rman Target/
Crosscheck backup;
DELETE obsolete;
DELETE expired backup;
Crosscheck Archivelog All;
DELETE expired Archivelog All;
--Method 2
Rman Target/
Allocate channel for maintenance type disk;
DELETE obsolete device type disk;
How to get SQL the implementation plan, from AWR in the report to find the SQL of the SQL ID , and then use the following SQL Get:
SELECT * from TABLE (dbms_xplan.display_cursor (' ATFWCG8ANRYKP '));
The code for a lock table query is in the following form:
Select COUNT (*) from V$locked_object;
SELECT * Fromv$locked_object;
See which table is locked
Select B.owner,b.object_name,a.session_id,a.locked_mode
From V$locked_object a,dba_objects b
where b.object_id = a.object_id;
See which session caused it.
Select B.username,b.sid,b.serial#,logon_time
From V$locked_object a,v$session b
where a.session_id = B.sid order by B.logon_time;
Kill the corresponding process and execute the command:
Alter system kill session ' 1025,41 ';
1025 of them are sid,41 for serial#.
Oracle Common SQL