What is the relationship among database, tablespace and data file?

An Oracle database contains one or more logical storage units called tablespaces. These tablespaces collectively store whole data of databases and each tablespace in Oracle database consists of one or more files called datafiles. These datafiles are physical structure that confirm with the operating system in which Oracle is running.

In Oracle, the relationship among a database, tablespace, and data file is as follows:

  1. Database:
    • A database in Oracle is a collection of physical and logical structures that stores and manages data.
  2. Tablespace:
    • A tablespace is a logical storage container within an Oracle database.
    • It consists of one or more data files or temp files.
    • Tables and indexes are created within a tablespace.
    • Each tablespace is associated with one database, but a database can have multiple tablespaces.
  3. Data File:
    • A data file is a physical file on the disk that belongs to a tablespace.
    • Data files store the actual data of the database.
    • Each tablespace can have one or more data files associated with it.
    • Data files are where the data is physically stored on the operating system.

So, in summary, a database contains one or more tablespaces, and each tablespace consists of one or more data files. Data files are the physical storage units where the actual data of the database is stored, and tablespaces provide a logical grouping for the data files. Tables and indexes are then created within specific tablespaces.