database 数据库模式与数据库表空间?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35120219/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
A database schema vs a database tablespace?
提问by user2052752
Doing my databases reading when I read...
当我阅读时做我的数据库阅读...
Schema: Is a container for objects
Schema:是对象的容器
Tablespace: A logical storage unit for objects
表空间:对象的逻辑存储单元
Can anyone explain the difference between these?
任何人都可以解释这些之间的区别吗?
回答by a_horse_with_no_name
A schema is a namespace - a logical thing. It is used to organize the namesof 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 differenttable 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.
单个对象(例如表)可以分布在多个表空间(取决于所使用的 DBMS),但它只能在单个模式中定义。该表schema_1.table_1
是一个不同的表schema_2.table_1
- 尽管“普通”名称相同,但完全限定名称不同,因此它们是两个不同的表。
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.
模式(和目录,是另一个级别的命名空间)是 SQL 语言的一部分,并在 SQL 标准中定义。
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.
表空间是物理存储的一部分并且是 DBMS 特定的(尽管几乎所有 DBMS 都支持类似的概念),而不是 SQL 查询语言(由 SQL 标准定义)的一部分。但是,它们是通过供应商特定的 SQL/DDL 语句定义和管理的。
回答by RomanPerekhrest
Schemaoperates the logical structures.
While Tablespacesoperate physical datafiles that constitute the database.
模式操作逻辑结构。
虽然表空间操作构成数据库的物理数据文件。
From Oracledocumentation:
来自Oracle文档:
Schema:
A schemais a collection of database objects. A schema is owned by a database user and has the same name as that user. Schema objectsare 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
模式:
一个模式是数据库对象的集合。模式归数据库用户所有,并与该用户同名。模式对象是直接引用数据库数据的逻辑结构。模式对象包括表、视图和 索引等结构。(表空间和模式之间没有关系。同一个模式中的对象可以在不同的表空间中,一个表空间可以保存来自不同模式的对象。)表空间:
一个数据库被分成一个或多个称为表空间的逻辑存储单元。表空间被划分为称为段的逻辑存储单元,这些逻辑单元又被进一步划分为区。范围是连续块的集合。表空间的大小是构成表空间的数据文件的大小。数据库的大小是构成数据库的表空间的总大小。您可以通过三种方式扩大数据库:
Add a datafile to a tablespace Add a new tablespace Increase the size of a datafile
回答by JLP
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
来自甲骨文文档。 https://docs.oracle.com/cd/B10500_01/server.920/a96524/c11schem.htm