Oracle Database allocates logical space for all data in the database. The logical units of database space allocation are data blocks, extents, segments, and tablespaces. At a physical level, the data is stored in data files on disk. The data in the data files is stored in operating system blocks.
Oracle database logically divided into tow or more tablespaces ,a database is divided into logical storage units called tablespaces, which group related data blocks, extents, and segments.
The combined size of the datafiles in a tablespace is the total storage capacity of the tablespace.Every Oracle database contains a SYSTEM tablespace and a SYSAUX tablespace. Oracle Database creates them automatically when the database is created.
Below diagram for physical and logical storage
Tablespaces logically organize data that are physically stored in datafiles.
- A tablespace belongs to only one database, and has at least one datafile that is used to store data for the associated tablespace.
- The term "tablespaces" is misleading because a tablespace can store tables, but can also store many other database objects such as indexes, views, sequences, etc.
- Datafiles are always assigned to only one tablespace and, therefore, to only one database.
- Tablespace is contain one or more segments (table,index etc).
Logical Storage Hierarchy:
A segment contains one or more extents, each of which contains multiple data blocks.A data block is the smallest logical unit of data storage in Oracle Database.
One logical data block corresponds to a specific number of bytes of physical disk space, for example, 2 KB. Data blocks are the smallest units of storage that Oracle Database can use or allocate.
Extent
An extent is a set of logically contiguous data blocks allocated for storing a specific type of information .In the preceding graphic, the 24 KB extent has 12 data blocks, while the 72 KB extent has 36 data blocks.
Segment
A segment is a set of extents allocated for a specific database object, such as a table.
For example, the data for the employees table is stored in its own data segment, whereas each index for employees is stored in its own index segment. Every database object that consumes storage consists of a single segment.
A tablespace is a database storage unit that contains one or more segments.
- A database is made up of one or more tablespaces
- A tablespace is made up of one or more data files, a tablespace contains segments
- A segment (table, index, etc) is made up of one or more extents. A segment exists in a tablespace but may have data in many data files within a tablespace.
- An extent is a continuous set of blocks on a disk. An extent is in a single tablespace and is always in a single file within that tablespace.
- A block is the smallest unit of allocation in the database. A block is the smallest unit of i/o used by the database.