A database schema vs a database tablespace?

后端 未结 3 1972
轮回少年
轮回少年 2021-02-01 03:38

Doing my databases reading when I read...

Schema: Is a container for objects

Tablespace: A logical storage unit for objects

Can anyone explain the differ

相关标签:
3条回答
  • 2021-02-01 04:21

    A schema is a namespace - a logical thing. It is used to organize the names of database objects. It has nothing to do with the way the data is stored.

    A tablespace is a physical thing. It's a container for data and has nothing to do with the logical organization of the database objects.

    A single object (e.g. a table) could be spread across multiple tablespaces (depending on the DBMS being used) but it can only be defined in a single schema. The table schema_1.table_1 is a different table than schema_2.table_1 - although the "plain" name is the same, the fully qualified name is different and therefore those are two different tables.

    Objects that are organized in the same schema are not necessarily stored in the same tablespace. And a single tablespace can contain objects from different schemas.

    Schemas (and catalogs, which are another level of namespace) are part of the SQL language and are defined in the SQL standard.

    Tablespaces are part of the physical storage and are DBMS-specific (although nearly all DBMS support a concept like that) and are not part of the SQL query language (as defined by the SQL standard). They are, however, defined and managed through vendor-specific SQL/DDL statements.

    0 讨论(0)
  • 2021-02-01 04:30

    Schema operates the logical structures.
    While Tablespaces operate physical datafiles that constitute the database.

    From Oracle documentation:

    Schema:
    A schema is a collection of database objects. A schema is owned by a database user and has the same name as that user. Schema objects are the logical structures that directly refer to the database's data. Schema objects include structures like tables, views, and indexes. (There is no relationship between a tablespace and a schema. Objects in the same schema can be in different tablespaces, and a tablespace can hold objects from different schemas.)

    Tablespaces:
    A database is divided into one or more logical storage units called tablespaces. Tablespaces are divided into logical units of storage called segments, which are further divided into extents. Extents are a collection of contiguous blocks. The size of a tablespace is the size of the datafiles that constitute the tablespace. The size of a database is the collective size of the tablespaces that constitute the database.

    You can enlarge a database in three ways:

    Add a datafile to a tablespace
    
    Add a new tablespace
    
    Increase the size of a datafile
    
    0 讨论(0)
  • 2021-02-01 04:33

    There is no relationship between schemas and tablespaces: a tablespace can contain objects from different schemas, and the objects for a schema can be contained in different tablespaces.

    FROM ORACLE DOCUMENTATION. https://docs.oracle.com/cd/B10500_01/server.920/a96524/c11schem.htm

    0 讨论(0)
提交回复
热议问题