search
HomeDatabaseOracleWhat is oracle tablespace

What is oracle tablespace

Dec 24, 2021 am 11:54 AM
oracletable space

Oracle table space is a logical division of the database and the smallest unit for Oracle database recovery. It accommodates many database entities, such as tables, views, indexes, clusters, rollback segments, temporary segments, etc. An Oracle database can have one or more table spaces, and a table space corresponds to one or more physical database files.

What is oracle tablespace

The operating environment of this tutorial: Windows 7 system, Oracle 11g version, Dell G3 computer.

1. Concept

Oracle tablespaces (tablespaces) is a logical concept. Data files are what actually store data. An Oracle database can have one or more table spaces, and a table space corresponds to one or more physical database files.

Table space is the smallest unit for Oracle database recovery, housing many database entities, such as tables, views, indexes, clusters, rollback segments, temporary segments, etc.

1. Features of Oracle table space:

(1) Control database data disk allocation;

(2) Restrict users in the table space The amount of disk space that can be used;

(3) The table space has online, offline, readonly, and readwrite attributes.

2. Classification of table spaces:

  • Permanent table space: some objects to be permanently stored in the database, such as: tables, views , Stored procedure

  • Temporary table space: The process executed in the middle of the database operation. After the execution is completed, the stored content will be automatically released

  • UNDO table space: used to save the old values ​​​​of transaction modified data, and can roll back the data

Segment (segment) refers to the space occupied by the data file Common name, or a collection of space used by database objects; segments can include table segments, index segments, rollback segments, temporary segments, cache segments, etc.

Extent (Interval/Extension), any continuous block allocated to an object (such as a table) is called an interval; the interval is also called an extension, because when it uses up the allocated interval, it will When new records are inserted, a new interval must be allocated (that is, some blocks are extended); once the interval is allocated to an object (table, index, and cluster), the interval cannot be allocated to other objects.

What is oracle tablespace
Structural diagram

What is oracle tablespace
datafile, segment, extend relationship diagram

select * from dba_data_files;   --describes database files  数据文件信息
select * from dba_temp_files;   --describes all temporary files (tempfiles) in the database 临时数据文件信息
select * from dba_free_space;   --describes the free extents in all tablespaces in the database 数据库中所有表空间中的空闲扩展区
select * from dba_segments;     --describes the storage allocated for all segments in the database 数据库中的所有段分配的存储

What is oracle tablespace

What is oracle tablespace

What is oracle tablespace

1. Create table space

--语法:
create [temporary] tablespace tablespace_name tempfile|datafile ‘xx.dbf’ size xx;
--创建临时表空间时,加上temporary关键字;

2. Expand the table space. When a certain table space is used up, the insert operation can no longer be performed on the database table. At this time, we need to expand the table space. , you can expand the table space by adding datafile files.

select f.* from dba_data_files f where f.tablespace_name='MLT';--查看表空间信息

alter tablespace MLT --表空间名
     add datafile '/home/oracle/oradata/crm/mlt04.dbf'  --datafile文件路径
     size 100M --表空间大小
     autoextend on --自动扩展

What is oracle tablespace

3. Modify the status of the table space

alter tablespace tablespace_name online|offline;--表空间是脱机时不可用,默认是联机的

4. Delete table space

drop tablespace tablespace_name[including contents];
--including contents 表示删除表空间包括datafile数据文件,不加则不删除相关数据文件;
--删除数据文件时,不能删除表空间当中第一个数据文件,如果要删除就需要删除整个表空间。

5. Check table space usage

--查询表空间使用情况SELECT Upper(F.TABLESPACE_NAME)         "表空间名",
       D.TOT_GROOTTE_MB                 "表空间大小(M)",
       D.TOT_GROOTTE_MB - F.TOTAL_BYTES "已使用空间(M)",
       To_char(Round(( D.TOT_GROOTTE_MB - F.TOTAL_BYTES ) / D.TOT_GROOTTE_MB * 100, 2), '990.99')
       || '%'                           "使用比",
       F.TOTAL_BYTES                    "空闲空间(M)",
       F.MAX_BYTES                      "最大块(M)"FROM   (SELECT TABLESPACE_NAME,
               Round(Sum(BYTES) / ( 1024 * 1024 ), 2) TOTAL_BYTES,
               Round(Max(BYTES) / ( 1024 * 1024 ), 2) MAX_BYTES
        FROM   SYS.DBA_FREE_SPACE
        GROUP  BY TABLESPACE_NAME) F,
       (SELECT DD.TABLESPACE_NAME,
               Round(Sum(DD.BYTES) / ( 1024 * 1024 ), 2) TOT_GROOTTE_MB
        FROM   SYS.DBA_DATA_FILES DD
        GROUP  BY DD.TABLESPACE_NAME) DWHERE  D.TABLESPACE_NAME = F.TABLESPACE_NAME--查询表空间的空闲扩展区select tablespace_name, count(*) AS extends,round(sum(bytes) / 1024 / 1024, 2) AS 大小/MB,sum(blocks) AS blocks from dba_free_space group BY tablespace_name;--查询表空间的总容量select tablespace_name, sum(bytes) / 1024 / 1024 as MB from dba_data_files group by tablespace_name;--查询表空间使用率SELECT total.tablespace_name,
       Round(total.MB, 2)           AS   总量/MB,
       Round(total.MB - free.MB, 2) AS  已使用/MB,
       Round(( 1 - free.MB / total.MB ) * 100, 2) || '%'                  AS  使用率FROM   (SELECT tablespace_name,
               Sum(bytes) / 1024 / 1024 AS MB
        FROM   dba_free_space
        GROUP  BY tablespace_name) free,
       (SELECT tablespace_name,
               Sum(bytes) / 1024 / 1024 AS MB
        FROM   dba_data_files
        GROUP  BY tablespace_name) totalWHERE  free.tablespace_name = total.tablespace_name;

Recommended tutorial: "Oracle Tutorial

The above is the detailed content of What is oracle tablespace. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
The Role of Oracle Software: Streamlining Business ProcessesThe Role of Oracle Software: Streamlining Business ProcessesMay 10, 2025 am 12:19 AM

Oracle software simplifies business processes through database management, ERP, CRM and data analysis capabilities. 1) OracleERPCloud automates financial, human resources and other processes; 2) OracleCXCloud manages customer interactions and provides personalized services; 3) OracleAnalyticsCloud supports data analysis and decision-making.

Oracle's Software Suite: Products and Services ExplainedOracle's Software Suite: Products and Services ExplainedMay 09, 2025 am 12:12 AM

Oracle's software suite includes database management, ERP, CRM, etc., helps enterprises optimize operations, improve efficiency, and reduce costs. 1. OracleDatabase manages data, 2. OracleERPCloud handles finance, human resources and supply chain, 3. Use OracleSCMCloud to optimize supply chain management, 4. Ensure data flow and consistency through APIs and integration tools.

MySQL vs. Oracle: Licensing, Features, and BenefitsMySQL vs. Oracle: Licensing, Features, and BenefitsMay 08, 2025 am 12:05 AM

The main difference between MySQL and Oracle is licenses, features, and advantages. 1. License: MySQL provides a GPL license for free use, and Oracle adopts a proprietary license, which is expensive. 2. Function: MySQL has simple functions and is suitable for web applications and small and medium-sized enterprises. Oracle has powerful functions and is suitable for large-scale data and complex businesses. 3. Advantages: MySQL is open source free, suitable for startups, and Oracle is reliable in performance, suitable for large enterprises.

MySQL vs. Oracle: Selecting the Right Database SystemMySQL vs. Oracle: Selecting the Right Database SystemMay 07, 2025 am 12:09 AM

MySQL and Oracle have significant differences in performance, cost and usage scenarios. 1) Performance: Oracle performs better in complex queries and high concurrency environments. 2) Cost: MySQL is open source, low cost, suitable for small and medium-sized projects; Oracle is commercialized, high cost, suitable for large enterprises. 3) Usage scenarios: MySQL is suitable for web applications and small and medium-sized enterprises, and Oracle is suitable for complex enterprise-level applications. When choosing, you need to weigh the specific needs.

Oracle Software: Maximizing Efficiency and PerformanceOracle Software: Maximizing Efficiency and PerformanceMay 06, 2025 am 12:07 AM

Oracle software can improve performance in a variety of ways. 1) Optimize SQL queries and reduce data transmission; 2) Appropriately manage indexes to balance query speed and maintenance costs; 3) Reasonably configure memory, optimize SGA and PGA; 4) Reduce I/O operations and use appropriate storage devices.

Oracle: Enterprise Software and Cloud ComputingOracle: Enterprise Software and Cloud ComputingMay 05, 2025 am 12:01 AM

Oracle is so important in the enterprise software and cloud computing sectors because of its comprehensive solutions and strong technical support. 1) Oracle provides a wide range of product lines from database management to ERP, 2) its cloud computing services such as OracleCloudPlatform and Infrastructure help enterprises achieve digital transformation, 3) Oracle database stability and performance and seamless integration of cloud services improve enterprise efficiency.

MySQL vs. Oracle: A Comparative Analysis of Database SystemsMySQL vs. Oracle: A Comparative Analysis of Database SystemsMay 04, 2025 am 12:13 AM

MySQL and Oracle have their own advantages and disadvantages, and comprehensive considerations should be taken into account when choosing: 1. MySQL is suitable for lightweight and easy-to-use needs, suitable for web applications and small and medium-sized enterprises; 2. Oracle is suitable for powerful functions and high reliability needs, suitable for large enterprises and complex business systems.

MySQL vs. Oracle: Understanding Licensing and CostMySQL vs. Oracle: Understanding Licensing and CostMay 03, 2025 am 12:19 AM

MySQL uses GPL and commercial licenses for small and open source projects; Oracle uses commercial licenses for enterprises that require high performance. MySQL's GPL license is free, and commercial licenses require payment; Oracle license fees are calculated based on processors or users, and the cost is relatively high.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool