Which SQL statements are commonly used for Oracle maintenance?

Source: Internet
Author: User

The following articles mainly introduce SQL statements commonly used for Oracle maintenance. If you are a computer, I believe that after reading this article, you will have a better understanding of the relevant SQL statements. The following describes the specific content of this article.
 

1. view the table space name and size.

 
 
  1. select t.tablespace_name, round(sum(bytes/(1024*1024)),0) ts_size   
  2. from dba_tablespaces t, dba_data_files d   
  3. where t.tablespace_name = d.tablespace_name   
  4. group by t.tablespace_name;   
  5.  

2. view the name and size of the tablespace physical file.

 
 
  1. select tablespace_name, file_id, file_name,   
  2. round(bytes/(1024*1024),0) total_space   
  3. from dba_data_files   
  4. order by tablespace_name;   

3. Check the rollback segment name and size.

 
 
  1. select segment_name, tablespace_name, r.status,   
  2. (initial_extent/1024) InitialExtent,(next_extent/1024) NextExtent,   
  3. max_extents, v.curext CurExtent   
  4. From dba_rollback_segs r, v$rollstat v   
  5. Where r.segment_id = v.usn(+)   
  6. order by segment_name ;   

4. View Control Files

 
 
  1. select name from v$controlfile;  

5. You need to view the log files in common Oracle maintenance SQL statements.

 
 
  1. select member from v$logfile;  

6. View table space usage

 
 
  1. select sum(bytes)/(1024*1024) as free_space,tablespace_name   
  2. from dba_free_space   
  3. group by tablespace_name;   
  4. SELECT A.TABLESPACE_NAME,A.BYTES TOTAL,B.BYTES USED, C.BYTES FREE,   
  5. (B.BYTES*100)/A.BYTES "% USED",(C.BYTES*100)/A.BYTES "% FREE"   
  6. FROM SYS.SM$TS_AVAIL A,SYS.SM$TS_USED B,SYS.SM$TS_FREE C   
  7. WHERE A.TABLESPACE_NAME=B.TABLESPACE_NAME AND A.TABLESPACE_NAME=C.TABLESPACE_NAME;   

7. view database objects

 
 
  1. select owner, object_type, status, count(*) 
    count# from all_objects group by owner, object_type, status;  

8. view the database version

 
 
  1. Select version FROM Product_component_version   
  2. Where SUBSTR(PRODUCT,1,6)=''Oracle'';   

9. view the database creation date and archiving method

 
 
  1. Select Created, Log_Mode, Log_Mode From V$Database;  

10. Capture SQL statements that have been running for a long time

 
 
  1. column username format a12   
  2. column opname format a16   
  3. column progress format a8   
  4. select username,sid,opname,   
  5. round(sofar*100 / totalwork,0) ''%'' as progress,   
  6. time_remaining,sql_text   
  7. from v$session_longops , v$sql   
  8. where time_remaining <> 0   
  9. and sql_address = address   
  10. and sql_hash_value = hash_value   
  11. /   
  12.  

The above content is an introduction to common SQL statements for Oracle maintenance. I hope you will find some gains.

Article by: http://www.programbbs.com/doc/class10-3.htm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.