mysql bse什么意思_数据库中的 Schema 是什么?

2ff34e647e2e3cdfd8dca593e17d9b0a.png

在数据库中,schema(发音 “skee-muh” 或者“skee-mah”,中文叫模式)是数据库的组织和结构,schemas andschemata都可以作为复数形式。模式中包含了schema对象,可以是表(table)、列(column)、数据类型(data type)、视图(view)、存储过程(stored procedures)、关系(relationships)、主键(primary key)、外键(foreign key)等。数据库模式可以用一个可视化的图来表示,它显示了数据库对象及其相互之间的关系。

其实可以理解成用来存储数据库元数据信息的一个东西。

Schema 和 DataBase 是否等同?

涉及到数据库的模式有很多疑惑,问题经常出现在模式和数据库之间是否有区别,如果有,区别在哪里。MySQL的文档中指出,在物理上,模式与数据库是同义的,所以,模式和数据库是一回事。

但是,Oracle的文档却指出,某些对象可以存储在数据库中,但不能存储在schema中。 因此,模式和数据库不是一回事。

而根据这篇SQL Server技术文章SQLServer technical article.aspx),schema是数据库SQL Server内部的一个独立的实体。 所以,他们也不是一回事。

SQL 标准对 schema 如何定义?

ISO/IEC 9075-1 SQL标准中将 schema 定义为描述符的持久命名集合(a persistent, named collection of descriptors)

schema一词源于希腊语skhēma,意思是形态(form),轮廓(figure),形状(shape)或方案(plan)。

以下是三个领先的关系数据库系统的schema定义:

mysql

Conceptually, a schema is a set of interrelated database objects, such as tables, table columns, data types of the columns, indexes, foreign keys, and so on. These objects are connected through SQL syntax, because the columns make up the tables, the foreign keys refer to tables and columns, and so on. Ideally, they are also connected logically, working together as part of a unified application or flexible framework. For example, theINFORMATION_SCHEMA and performance_schema databases use “schema” in their names to emphasize the close relationships between the tables and columns they contain.

In MySQL, physically, aschema is synonymous with adatabase. You can substitute the keywordSCHEMA instead ofDATABASEin MySQL SQL syntax, for example using CREATE SCHEMA instead of CREATE DATABASE.

Some other database products draw a distinction. For example, in the Oracle Database product, aschema represents only a part of a database: the tables and other objects owned by a single user.

MySQL官方文档指出,从概念上讲,模式是一组相互关联的数据库对象,如表,表列,列的数据类型,索引,外键等等。但是从物理层面上来说,模式与数据库是同义的。你可以在MySQL的SQL语法中用关键字SCHEMA替代DATABASE,例如使用CREATE SCHEMA来代替CREATE DATABASE。

SQL Server

The names of tables, fields, data types, and primary and foreign keys of a database.

SQL Server官方文档指出,schema中包含了数据库的表,字段,数据类型以及主键和外键的名称。

Oracle Database

A schema is a collection of logical structures of data, or schema objects. A schema is owned by a database user and has the same name as that user. Each user owns a single schema.

Oracle官方文档指出,schema是数据或模式对象的逻辑结构的集合,由数据库用户拥有,并且与该用户具有相同的名称,也就是说每个用户拥有一个独立的schema。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值