Oracle 中用户和模式之间的区别?
Oracle 中的用户和模式有什么区别?
What is the difference between a user and a schema in Oracle?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
Oracle 中的用户和模式有什么区别?
What is the difference between a user and a schema in Oracle?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(16)
模式是对象的容器。
它由用户拥有。
Schema is a container of objects.
It is owned by a user.
好吧,我在某处读到,如果您的数据库用户具有 DDL 权限,那么它就是一个架构,否则它就是一个用户。
Well, I read somewhere that if your database user has the DDL privileges then it's a schema, else it's a user.
来自询问 Tom
From Ask Tom
我认为问题在于 Oracle 使用的术语“架构”与通常的含义略有不同。
意义 2 中的架构类似,但与意义 1 中的架构不同。例如,对于使用多个数据库帐户,意义 2 中的模式可能由多个 Oracle 模式组成:-)。
另外,模式还可以表示其他上下文中(例如数学)中的一堆其他相当不相关的事物。
Oracle 应该只使用“userarea”或“accountobjects”之类的术语,而不是重载“schema”...
I believe the problem is that Oracle uses the term schema slightly differently from what it generally means.
Schema in sense 2. is similar, but not the same as schema in sense 1. E.g. for an application that uses several DB accounts, a schema in sense 2 might consist of several Oracle schemas :-).
Plus schema can also mean a bunch of other, fairly unrelated things in other contexts (e.g. in mathematics).
Oracle should just have used a term like "userarea" or "accountobjects", instead of overloadin "schema"...
来自 WikiAnswers:
此外,如果用户有权限的话,他们还可以访问自己架构之外的对象。
From WikiAnswers:
Furthermore, a user can access objects in schemas other than their own, if they have permission to do so.
像平常一样将用户(有权登录并访问系统中的某些对象的用户名/密码)和模式视为用户主目录的数据库版本。 用户“foo”通常在模式“foo”下创建事物,例如,如果用户“foo”创建或引用表“bar”,那么Oracle将假定该用户意味着“foo.bar”。
Think of a user as you normally do (username/password with access to log in and access some objects in the system) and a schema as the database version of a user's home directory. User "foo" generally creates things under schema "foo" for example, if user "foo" creates or refers to table "bar" then Oracle will assume that the user means "foo.bar".
这个答案没有定义所有者和模式之间的区别,但我认为它增加了讨论。
在我的小思考世界中:
我一直在努力思考创建 N 个用户,我希望这些用户中的每一个“消费”(也称为使用)单个模式。
oracle-base.com 上的 Tim 展示了如何执行此操作 (有 N 个用户,每个用户都将被“重定向”到单个模式。
他有第二种“同义词”方法(此处未列出)。我在这里仅引用 CURRENT_SCHEMA 版本(他的方法之一):
This answer does not define the difference between an owner and schema but I think it adds to the discussion.
In my little world of thinking:
I have struggled with the idea that I create N number of users where I want each of these users to "consume" (aka, use) a single schema.
Tim at oracle-base.com shows how to do this (have N number of users and each of these users will be "redirected" to a single schema.
He has a second "synonym" approach (not listed here). I am only quoting the CURRENT_SCHEMA version (one of his approaches) here:
这很简单。
用户可以被授予对不同用户拥有的模式对象的访问权。
It's very simple.
A user may be given access to schema objects owned by different Users.
模式是关于感兴趣的想法/领域的 DB.objects 的封装,并由一个用户拥有。 然后,它将由具有受抑制角色的其他用户/应用程序共享。 因此,用户不需要拥有模式,但模式需要有所有者。
Schema is an encapsulation of DB.objects about an idea/domain of intrest, and owned by ONE user. It then will be shared by other users/applications with suppressed roles. So users need not own a schema, but a schema needs to have an owner.
--USER 和 SCHEMA
用户和模式这两个词是可以互换的,这就是为什么大多数人对这个词感到困惑,下面我解释了它们之间的区别
--User 用户是连接数据库(服务器)的帐户。 我们可以使用 CREATE USER user_name IDENTIFIED BY password 来创建用户。
--Schema
实际上Oracle数据库包含处理数据的逻辑和物理结构。Schema也是处理数据库(内存组件)中数据的逻辑结构。 它是在创建用户时由 oracle 自动创建的。它包含由与该模式关联的用户创建的所有对象。例如,如果我创建了一个名为 santhosh 的用户,那么 oracle 创建了一个名为 santhosh 的模式,oracle 将用户 santhosh 创建的所有对象存储在 santhosh 中架构。
我们可以通过 CREATE SCHEMA 语句创建模式,但是 Oracle 会自动为该模式创建用户。
我们可以使用 DROP SCHEMA scama_name RESTRICT 语句删除模式,但它不能删除包含对象的模式,因此要删除模式,它必须为空。这里的限制字强制指定不包含对象的模式。
如果我们尝试删除用户架构中的包含对象,我们必须指定 CASCADE 单词,因为 Oracle 不允许删除用户包含对象。
DROP USER 用户名 CASCADE
因此,oracle 删除模式中的对象,然后自动删除用户,从其他模式(如视图和私有同义词)引用此模式对象的对象将进入无效状态。
--USER and SCHEMA
The both words user and schema are interchangeble,thats why most people get confusion on this words below i explained the difference between them
--User User is a account to connect database(Server). we can create user by using CREATE USER user_name IDENTIFIED BY password .
--Schema
Actually Oracle Database contain logical and physical strucutre to process the data.The Schema Also Logical Structure to process the data in Database(Memory Component). Its Created automatically by oracle when user created.It Contains All Objects created by the user associated to that schema.For Example if i created a user with name santhosh then oracle createts a schema called santhosh,oracle stores all objects created by user santhosh in santhosh schema.
We can create schema by CREATE SCHEMA statement ,but Oracle Automatically create a user for that schema.
We can Drop the schema by using DROP SCHEMA schama_name RESTRICT statement but it can not delete scehema contains objects,so to drop schema it must be empty.here the restrict word forcely specify that schema with out objects.
If we try to drop a user contain objects in his schema we must specify CASCADE word because oracle does not allow you to delete user contain objects.
DROP USER user_name CASCADE
so oracle deletes the objects in schema and then it drops the user automatically,Objects refered to this schema objects from other schema like views and private synonyms goes to invalid state.
基于我对 Oracle 的一点了解......用户和架构有点相似。 但也有一个重大区别。 如果“用户”拥有任何对象,则用户可以称为模式,否则......它将仅保留为“用户”。 一旦用户拥有至少一个对象,那么根据上面的所有定义......用户现在可以称为模式。
Based on my little knowledge of Oracle... a USER and a SCHEMA are somewhat similar. But there is also a major difference. A USER can be called a SCHEMA if the "USER" owns any object, otherwise ... it will only remain a "USER". Once the USER owns at least one object then by virtue of all of your definitions above.... the USER can now be called a SCHEMA.
用户帐户就像持有您家钥匙的亲戚,但不拥有任何东西,即用户帐户不拥有任何数据库对象...没有数据字典...
而模式是数据库对象的封装。 这就像房子的主人拥有你房子里的所有东西,只有当主人(即模式)向它提供所需的补助时,用户帐户才能够访问家里的物品。
A user account is like relatives who holds a key to your home, but does not own anything i.e. a user account does not own any database object...no data dictionary...
Whereas a schema is an encapsulation of database objects. It's like the owner of the house who owns everything in your house and a user account will be able to access the goods at the home only when the owner i.e. schema gives needed grants to it.
对于大多数更熟悉 MariaDB 或 MySQL 的人来说,这似乎不太令人困惑,因为在 MariaDB 或 MySQL 中,它们具有不同的模式(包括不同的表、视图、PLSQL 块和数据库对象等),而 USERS 是可以访问这些模式的帐户。架构。 因此,没有特定的用户可以属于任何特定的模式。 必须向该架构授予权限,然后用户才能访问它。 在 MySQL 和 MariaDB 等数据库中,用户和架构是分开的。
在 Oracle 中,模式和用户几乎被视为相同。 要使用该模式,您需要拥有权限,您会觉得模式名称只是用户名。 可以跨模式授予权限,以从不同模式访问不同的数据库对象。 在 Oracle 中,我们可以说用户拥有模式,因为当您创建用户时,您会为其创建数据库对象,反之亦然。
For most of the people who are more familiar with MariaDB or MySQL this seems little confusing because in MariaDB or MySQL they have different schemas (which includes different tables, view , PLSQL blocks and DB objects etc) and USERS are the accounts which can access those schema. Therefore no specific user can belong to any particular schema. The permission has be to given to that Schema then the user can access it. The Users and Schema is separated in databases like MySQL and MariaDB.
In Oracle schema and users are almost treated as same. To work with that schema you need to have the permission which is where you will feel that the schema name is nothing but user name. Permissions can be given across schemas to access different database objects from different schema. In oracle we can say that a user owns a schema because when you create a user you create DB objects for it and vice a versa.
模式和数据库用户是相同的,但如果模式拥有数据库对象,并且他们可以执行其对象的任何操作,但用户只能访问对象,则在模式用户授予您适当的权限之前,他们无法执行任何 DDL 操作。
A schema and database users are same but if schema has owned database objects and they can do anything their object but user just access the objects, They can't DO any DDL operations until schema user give you the proper privileges.
用户:对数据库资源的访问。 就像进入房子的钥匙一样。
模式:有关数据库对象的信息的集合。 就像书中的索引一样,其中包含有关该章节的简短信息。
查看此处了解详细信息
User: Access to resource of the database. Like a key to enter a house.
Schema: Collection of information about database objects. Like Index in your book which contains the short information about the chapter.
Look here for details
用户是连接数据库服务器的帐户。
我们可以使用以下方法创建用户:
模式是特定用户的所有对象的集合。 用户只是数据库中的一个帐户。 作为外行,您可以将银行视为数据库,将您在该银行的帐户视为用户,并将您帐户下可用的所有内容(您的储蓄帐户、储物柜等)视为您的架构。
另请阅读此
User is a account to connect Database Server.
We can create user by using:
Schema is collection of all the objects for a particular user. User is just an account in the database . As a laymen you can think as Bank as a Database and Your account in that bank as User and all things available under your account (Ur saving account,Locker etc) as your schema.
Also read this