目录、模式、用户和数据库实例之间的关系 [英] Relationship between catalog, schema, user, and database instance

查看:43
本文介绍了目录、模式、用户和数据库实例之间的关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要比较不同供应商(Oracle、SQL Server、DB2、MySQL 和 PostgreSQL)的数据库,我如何唯一标识任何对象,我是否需要目录?例如,在 Java 的 DatabaseMetadata 中,我至少应该指定目录和模式 fooPattern.

To compare databases of different vendors (Oracle, SQL Server, DB2, MySQL, and PostgreSQL) how can I identify any object uniquely and do I need a catalog? For instance, In Java's DatabaseMetadata I should specify catalog and schema fooPattern at least.

目录是否只是数据存储的抽象?

Is it true that catalog is just an abstraction of data storage?

推荐答案

在 Oracle 中:

  • 服务器实例==数据库==目录==由同一执行引擎管理的所有数据
  • schema == 数据库中的命名空间,与用户帐户相同
  • user == schema owner == 命名账户,与 schema 相同,谁可以连接到数据库,谁拥有 schema 并使用可能在其他 schema 中的对象
  • 要识别正在运行的服务器中的任何对象,您需要(模式名称 + 对象名称)

在 PostgreSQL 中:

  • 服务器实例==数据库集群==所有数据由同一个执行引擎管理
  • database == catalog == db cluster内的单个数据库,与同一db cluster内的其他数据库隔离
  • schema == 数据库中的命名空间
  • user == 命名帐户,可以连接到数据库,分别拥有和使用每个允许的数据库中的对象
  • 要识别正在运行的服务器中的任何对象,您需要(数据库名称+架构名称+对象名称)

在 MySQL 中:

  • 服务器实例 == 没有用目录标识,只是一组数据库
  • 数据库 == 架构 == 目录 == 服务器内的命名空间.
  • user == 命名帐户,可以连接到服务器并使用(但不能拥有 - 没有所有权概念)一个或多个数据库中的对象
  • 要识别正在运行的服务器中的任何对象,您需要(数据库名称+对象名称)
  • server instance == not identified with catalog, just a set of databases
  • database == schema == catalog == a namespace within the server.
  • user == named account, who can connect to server and use (but can not own - no concept of ownership) objects in one or more databases
  • to identify any object in running server, you need (database name + object name)

在 Microsoft SQL Server 中:

  • 服务器实例 == 一组托管数据库
  • 数据库 == 服务器内的命名空间限定符,很少称为目录
  • schema == owner == 数据库内的命名空间,与数据库角色绑定,默认只使用dbo
  • user == 命名帐户,可以连接到服务器并使用(但不能拥有 - 架构作为所有者)一个或多个数据库中的对象
  • 要识别正在运行的服务器中的任何对象,您需要(数据库名称+所有者+对象名称)
  • server instance == set of managed databases
  • database == namespace qualifier within the server, rarely referred to as catalog
  • schema == owner == namespace within the database, tied to database roles, by default only dbo is used
  • user == named account, who can connect to server and use (but can not own - schema works as owner) objects in one or more databases
  • to identify any object in running server, you need (database name + owner + object name)

所以我认为你的问题的答案是:

So I think answer to your questions is:

  1. 这取决于实现,是否需要目录名称来标识对象.目录"、架构"和数据库"的含义因实现而异.

  1. It depends on implementation, whether catalog name is needed to identify objects. The meaning of "catalog", "schema" and "database" vary from one implementation to another.

是的,目录是数据存储的抽象.我认为它也应该定义为自包含的独立命名空间,但并非所有 SQL 引擎都这样做.

Yes, a catalog is an abstraction of data storage. I think it should be also defined as a self-contained isolated namespace, but not all SQL engines do it.

Databaseschema 已被所有供应商很好地定义.Catalog 有时与数据库"同义(至少在 Oracle 和 Postgres 中),有时与模式"同义,有时与两者同义.术语目录通常也表示元数据集合(又名系统表).

Database and schema are pretty well defined by all vendors. Catalog is sometimes synonymous to "database" (at least in Oracle and Postgres), sometimes synonymous to "schema", and sometimes synonymous to both. The term catalog also often means metadata collection (aka system tables).

这篇关于目录、模式、用户和数据库实例之间的关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆