Block, extent, segment, tablespace, data file relationship in oracle

Data files and log files are the most important files in a database. They are where data is stored. Each database has at least one data file associated with it, usually more than one, there are many. How is the data organized in the data file? To understand these contents, we must first understand what is a tablespace (tablespace), segment (segment), area (extent), block (block), these are the basic unit of the oracle database to organize data in data files. Now let's understand these concepts.
     A block is the physical unit of data storage and the most basic unit in a data file. Data is directly stored on the block. It is the smallest unit of oracle space allocation. There are three common block sizes in oracle, 2KB, 4KB, and 8KB. The size of the block is fixed when the database is created, the size of each block in the database is the same, and all blocks have the same format, which consists of "block header + table directory + row directory + free space + data space" composition. The block header contains information about the block type (such as a table block or an index block), the location of the block on the disk, and so on. The table directory, if any, contains information about the tables in which rows are stored in this block (if a block contains data from multiple tables). The row directory (row directory) contains the description information of the data row, it is an array of pointers, indicating the physical location of each row in the data block. The block header, table directory, and row directory are collectively referred to as block overhead, which is originally used by oracle to count and manage the block itself. The remaining two parts are very simple, the data space that has already stored data is the data space, and the free space that has not been stored temporarily.
     An area, also called an extent, is a contiguous allocation space in a data file, which is larger than a block and consists of blocks. Some objects may require at least two extents when allocating space, such as rollback segments, and these two extents may not necessarily be connected. The size of the area ranges from one block to 2GB
     . The segment is the allocation unit in the Oracle database. Objects such as tables and indexes are allocated in units of segments. A table segment is created when a table is created, and an index segment is created when an index is created. Every object that consumes storage space is eventually stored in a single segment. There are rollback segments, temporary segments, clustered segments, index segments, etc.
    A tablespace is a logical container that is associated with datafiles, and a tablespace has at least one datafile associated with it. A tablespace can have multiple segments, and a segment can only belong to one tablespace.
    A schema, also known as a schema, is a logical concept one level smaller than a tablespace, and it is also a logical container. Multiple users may share a table space, so how to distinguish each user? Then there is a corresponding scheme for each user in the tablespace, which is used to save the information of a single user.
    The hierarchical structure stored in oracle is summarized as follows:
1. The database consists of one or more tablespaces
2. The tablespace consists of one or more data files, and a tablespace contains multiple segments
3. The segment consists of one or more regions

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326092736&siteId=291194637