Oracle Check the size and usage of table space sql statement
SQL1:
--1、查看表空间的名称及大小 SELECT t.tablespace_name, round(SUM(bytes / (1024 * 1024)), 0) ts_size FROM dba_tablespaces t, dba_data_files d WHERE t.tablespace_name = d.tablespace_name GROUP BY t.tablespace_name; --2、查看表空间物理文件的名称及大小 SELECT tablespace_name, file_id, file_name, round(bytes / (1024 * 1024), 0) total_space FROM dba_data_files ORDER BY tablespace_name; --3、查看回滚段名称及大小 SELECT segment_name, tablespace_name, r.status, (initial_extent / 1024) initialextent, (next_extent / 1024) nextextent, max_extents, v.curext curextent FROM dba_rollback_segs r, v$rollstat v WHERE r.segment_id = v.usn(+) ORDER BY segment_name; --4、查看控制文件 SELECT NAME FROM v$controlfile; --5、查看日志文件 SELECT MEMBER FROM v$logfile; --6、查看表空间的使用情况 SELECT SUM(bytes) / (1024 * 1024) AS free_space, tablespace_name FROM dba_free_space GROUP BY tablespace_name; SELECT a.tablespace_name, a.bytes total, b.bytes used, c.bytes free, (b.bytes * 100) / a.bytes "% USED ", (c.bytes * 100) / a.bytes "% FREE " FROM sys.sm$ts_avail a, sys.sm$ts_used b, sys.sm$ts_free c WHERE a.tablespace_name = b.tablespace_name AND a.tablespace_name = c.tablespace_name; --7、查看数据库库对象 SELECT owner, object_type, status, COUNT(*) count# FROM all_objects GROUP BY owner, object_type, status; --8、查看数据库的版本 SELECT version FROM product_component_version WHERE substr(product, 1, 6) = 'Oracle'; --9、查看数据库的创建日期和归档方式 SELECT created, log_mode, log_mode FROM v$database;
SQL2:
--1G=1024MB --1M=1024KB --1K=1024Bytes --1M=11048576Bytes --1G=1024*11048576Bytes=11313741824Bytes SELECT a.tablespace_name "表空间名", total "表空间大小", free "表空间剩余大小", (total - free) "表空间使用大小", total / (1024 * 1024 * 1024) "表空间大小(G)", free / (1024 * 1024 * 1024) "表空间剩余大小(G)", (total - free) / (1024 * 1024 * 1024) "表空间使用大小(G)", round((total - free) / total, 4) * 100 "使用率 %" FROM (SELECT tablespace_name, SUM(bytes) free FROM dba_free_space GROUP BY tablespace_name) a, (SELECT tablespace_name, SUM(bytes) total FROM dba_data_files GROUP BY tablespace_name) b WHERE a.tablespace_name = b.tablespace_name
For more articles about Oracle checking the size and usage of table space sql statements, please pay attention to the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Oracle database is a commonly used relational database management system, and many users will encounter problems with the use of table spaces. In Oracle database, a user can have multiple table spaces, which can better manage data storage and organization. This article will explore how a user can have multiple table spaces in an Oracle database and provide specific code examples. In Oracle database, table space is a logical structure used to store objects such as tables, indexes, and views. Every database has at least one tablespace,

Title: Oracle table space query: View the table space where the table is located. Specific code examples are required. Oracle database is a commonly used type of enterprise-level database management system. The table space is the logical structure for storing data in the database. The table space starts in the database. plays an important role. In the Oracle database, to view the table space where the table is located, you can execute a SQL statement. The following will introduce how to query the table space where the table is located, and provide specific code examples. First, we need to understand Oracle data

Oracle database is a commonly used relational database management system, and table space is an important part of the database to store data. It is very important for database administrators and developers to understand how to query the size of table spaces. This article will introduce in detail the method of querying the table space size in the Oracle database and provide specific code examples. 1. Use the system view to query the size of the table space. In the Oracle database, you can query the size information of the table space through the system view. Commonly used system views include DBA

How to use Oracle to query table space capacity information In Oracle database, table space is a logical storage unit used to store tables, indexes and other database objects. Understanding the capacity information of the table space is very important for database administrators, which can help them monitor the space usage of the database and adjust the size of the table space in time to avoid insufficient space. This article will introduce how to use Oracle to query table space capacity information and provide specific code examples. 1. Query the total capacity, used capacity and

In-depth analysis of Oracle table space capacity query method In Oracle database management, table space is an important part used to store tables, indexes, views and other objects in the database. Understanding the capacity of table spaces is crucial for database administrators, which can help them perform storage management and planning in a timely manner. This article will deeply analyze the method of Oracle table space capacity query and give specific code examples. 1. Query the current usage of table space. To query the current usage of table space, you can use the following SQL

Introduction to query method of table space to which Oracle table belongs. In Oracle database, table space is a logical container used to store objects in the database. Each table belongs to a certain table space. Determining the tablespace to which a table belongs is important for database management and optimization. This article will introduce how to query the table space to which a table belongs in Oracle, including specific SQL code examples. Method 1: Use system tables to query Oracle's data dictionary, which stores a large amount of metadata information about database objects. We can query the data dictionary to

Oracle Database Management: How do users allocate tablespaces? Oracle database is a commonly used relational database management system. When users use Oracle database, they often need to manage table spaces. Table space is a logical storage unit used to store database objects (such as tables, indexes, etc.), which are composed of data files. In the Oracle database, each user will have a default table space, but sometimes users need to allocate additional table spaces to store data. This article will introduce how users allocate tables

How does Oracle view the table space to which a table belongs? Oracle database is a powerful relational database management system. Table space is an important concept used in Oracle database to manage data storage space. In Oracle, each table needs to be stored in a specific table space. By viewing the table space to which the table belongs, it can help the database administrator better manage the storage structure of the database. The following will introduce how to view the table space to which a table belongs in the Oracle database and provide specific code examples. exist
