暂无图片
暂无图片
1
暂无图片
暂无图片
暂无图片

Oracle的模式对象schema的介绍

原创 杨露瑶 恩墨学院 2022-10-09
1652

一、什么是schema

官方介绍
In Oracle Database, a database schema is a collection of logical data structures, or schema objects. A database schema is owned by a database user and has the same name as the user name. Schema objects are user-created structures that directly refer to the data in the database. The database supports many types of schema objects, the most important of which are tables and indexes.

A database schema is a logical container for data structures, called schema objects.

自我理解
模式是伴随着用户创建而创建的一个逻辑结构的容器,模式的名字与用户的名字相同且不可单独修改,这个集合包含了该用户对应的所有模式对象。

image.png

换句话说,schema就是以用户名字命名的一个概念仓库,就像我们在相处中想借某某的某个东西,而这里的某某是一个人的名字,而schema就类似于‘某某的’。虽然名字一样,但其实提到这个的时候就是想特指这个人的某样东西,而这个东西才是实质存在的。所以当我们提到schema时,一般指的是所有该用户下的模式对象,让我们查询schema时就是让我们去查询该用户下的所有表、索引、视图等一系列东西。

schema只是逻辑意义上存在的一个概念容器,等同于‘某某的’只是对于用户所拥有的东西的一个总称。

二、schema中包含有什么

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. Schema objects can be created and manipulated with SQL and include the following types of objects:

对象 备注
Clusters 聚簇
Constraints 约束
Database links 数据库链接
Database triggers 数据库触发器
Dimensions 维度
External procedure libraries 外部过程库
Index-organized tables 索引组织表
Indexes 索引
Indextypes 索引类型
Java classes, Java resources, Java sources Java类、Java资源、Java源
Materialized views 实例化视图
Materialized view logs 实例化视图日志
Mining models 挖掘模型
Object tables 对象表
Object types 对象类型
Object views 对象视图
Operators 操作员
PL/SQL subprograms and packages PL/SQL子程序和包
Sequences 序列
Stored functions, stored procedures 存储函数、存储过程
Synonyms 同义词
Tables
Views 视图

三、schema与用户之间的关系和区别

官方介绍
A database user has a password and various database privileges. Each user owns a single schema, which has the same name as the user. The schema contains the data for the user owning the schema. For example, the hr user owns the hr schema, which contains schema objects such as the employees table. In a production database, the schema owner usually represents a database application rather than a person.

Within a schema, each schema object of a particular type has a unique name. For example, hr.employees refers to the table employees in the hr schema. The figure depicts a schema owner named hr and schema objects within the hr schema.

HR Schema

自我理解
用户是一个用于连接并可以对数据库进行操作使用的一个实体,schema则代指该用户所拥有的所有模式对象的集合。

我们一般在特指一个表时常常使用scott.emp来代表,而这里的scott所指的并不是scott这个用户,而是scott这个同名的schema。用户与schema同时被创建并且拥有相同的名字,但用户详细所指的是拥有对数据库实例进行操作的一些权限的实体,而schema所指的是类似与表、索引这些逻辑上存在的对象的集合。

在创建一个用户时,会默认创建一个同名的schema;schema不能单独被创建;用户一般都伴随着密码出现,而schema一般用于要调用某个对象时,即conn scott/tiger使用的是user/passwd,而scott.emp使用的是schema.table

最后修改时间:2022-10-18 15:35:30
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

文章被以下合辑收录

评论