Query the table space and usage of the logon user name in the Oracle database

Source: Internet
Author: User

Oracle DatabaseYou can query the name of the logon user.TablespaceAnd table space usage? The answer is yes, but executing select username, default_tablespace from dba_users order by username requires the dba permission. This article introduces this implementation method, next let's take a look at it.

1. view the user's default tablespace name

First, you need to know the user name you are logged on to, and then log on with sysdba, and then execute the following statement:

 
 
  1. sqlplus / as sysdba  
  2.  
  3. select username,default_tablespace from dba_users; 

2. view the total table space size and the used table space size.

 
 
  1. select a.tablespace_name,a.bytes/1024/1024 "Sum MB",(a.bytes-b.bytes)/1024/1024 "used MB",b.bytes/1024/1024 "free MB",  
  2.  
  3. round(((a.bytes-b.bytes)/a.bytes)*100,2) "percent_used"  
  4.  
  5. from  
  6.  
  7. (select tablespace_name,sum(bytes) bytes from dba_data_files group by tablespace_name) a,  
  8.  
  9. (select tablespace_name,sum(bytes) bytes,max(bytes) largest from dba_free_space group by tablespace_name) b  
  10.  
  11. where a.tablespace_name=b.tablespace_name  
  12.  
  13. order by ((a.bytes-b.bytes)/a.bytes) desc; 

This article introduces how to view the tablespace to which the logon username belongs to the Oracle database. For more information about Oracle databases, see the article http://database.51cto.com/oracle/. it is a reliable solution.

Related Article

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.