这可能是一个非常糟糕的问题。但我一直将模式视为数据库中的表定义。这是错误的或不完全正确的。我不太记得我的数据库课程了。


当前回答

As https://www.informit.com/articles/article.aspx?p=30669

所有对象的名称在一定范围内必须是唯一的。每一个 数据库必须有唯一的名称;模式名称不能重复 在单个数据库的范围内,表的名称必须为 在单个模式的作用域中是唯一的,列名必须是 在表中是唯一的。类中索引的名称必须唯一 数据库。

其他回答

简而言之,模式是整个数据库的定义,因此它包括表、视图、存储过程、索引、主键和外键等。

As https://www.informit.com/articles/article.aspx?p=30669

所有对象的名称在一定范围内必须是唯一的。每一个 数据库必须有唯一的名称;模式名称不能重复 在单个数据库的范围内,表的名称必须为 在单个模式的作用域中是唯一的,列名必须是 在表中是唯一的。类中索引的名称必须唯一 数据库。

模式是数据库对象的集合,其中也包括逻辑结构。 它具有拥有它的用户的名称。 一个数据库可以有任意数量的Schema。 数据库中的一个表可以出现在两个同名的不同模式中。 用户可以查看已为其分配选择特权的任何模式。

来自PostgreSQL文档:

A database contains one or more named schemas, which in turn contain tables. Schemas also contain other kinds of named objects, including data types, functions, and operators. The same object name can be used in different schemas without conflict; for example, both schema1 and myschema can contain tables named mytable. Unlike databases, schemas are not rigidly separated: a user can access objects in any of the schemas in the database he is connected to, if he has privileges to do so. There are several reasons why one might want to use schemas: To allow many users to use one database without interfering with each other. To organize database objects into logical groups to make them more manageable. Third-party applications can be put into separate schemas so they do not collide with the names of other objects. Schemas are analogous to directories at the operating system level, except that schemas cannot be nested.

数据库模式是对表、视图、存储过程等对象进行逻辑分组的一种方式。把模式看作是对象的容器。 表是行和列的集合。 所有表的组合构成一个db。