Common SQL statements for Oracle Database Management

Source: Internet
Author: User
The CHUNKS column indicates the number of available idle blocks in the tablespace (each idle block is composed of some continuous Oracle data blocks). If there are too many idle blocks, such as average to each number

The CHUNKS column indicates the number of available idle blocks in the tablespace (each idle block is composed of some continuous Oracle data blocks). If there are too many idle blocks, such as average to each number

/*
The CHUNKS column indicates the number of available idle blocks in the tablespace (each idle block is composed of several consecutive Oracle data blocks). If there are too many idle blocks, for example, if there are more than 100 data files on average, the fragmentation of the tablespace is serious.
*/
Select tablespace_name,
Count (*) chunks,
Max (bytes/1024/1024) max_chunk
From dba_free_space
Group by tablespace_name;

/*
If the database uses Oracle jobs to complete some scheduled jobs, check the running status of these jobs:
Select job, log_user, last_date, failures
From dba_jobs;
If the FAILURES column is a number greater than 0, the JOB fails to run and further checks are required.
*/
Select job, log_user, last_date, failures from dba_jobs;


/*
DBAs should regularly check the database connection to check whether the number of sessions established with the database is normal. If too many connections are established, the database resources will be consumed. At the same time, DBA may need to manually clean up some "dead" connections.
Note: In the preceding example, sessions with SID ranging from 1 to 7 (the USERNAME column is empty) are the background processes of Oracle. do not perform any operations on these sessions.
*/
Select sid, serial #, username, program, machine, status
From v $ session;


/*
DBAs should regularly check the database connection to check whether the number of sessions established with the database is normal. If too many connections are established, the database resources will be consumed. At the same time, DBA may need to manually clean up some "dead" connections.
Note: sessions with SID ranging from 1 to 7 (the USERNAME column is empty) are the background processes of Oracle. do not perform any operations on these sessions.
*/
Alter system kill session 'sid, SERIAL #';

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.