What is the difference between a schema and a table and a database?

后端 未结 14 1180
一整个雨季
一整个雨季 2020-12-07 07:18

This is probably a n00blike (or worse) question. But I\'ve always viewed a schema as a table definition in a database. This is wrong or not entirely correct. I don\'t rememb

14条回答
  •  自闭症患者
    2020-12-07 07:36

    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.

    Official documentation can be referred https://www.postgresql.org/docs/9.1/ddl-schemas.html

提交回复
热议问题