日期:2014-05-16  浏览次数:20381 次

oracle user和schema区别
schema定义:
“A schema is a collection of database objects. A schema is owned by a database user and has the same name as that user. Schema objects are the logical structures that directly refer to the database's data. Schema objects include structures like tables, views, and indexes.(There is no relationship between a tablespace and a schema. Objects in the same schema can be in different tablespaces, and a tablespace can hold objects from different schemas.)”

官方文档里面说得比较明白,schema是数据对象的集合,包括像表、视图、索引、同义词等等都可以说是schema的对象。但不够生动,网上有篇文章里面把schema和user的关系用一个形象的比喻阐述得非常透彻,引用如下: 
  
“user即Oracle中的用户,和所有系统的中用户概念类似,用户所持有的是系统的权限及资源;而schema所涵盖的是各种对象,它包含了表、函数、包等等对象的“所在地”,并不包括对他们的权限控制。好比一个房子,里面放满了家具,对这些家具有支配权的是房子的主人(user),而不是房子(schema)。你可以也是一个房子的主人(user),拥有自己的房子(schema).可以通过alter session的方式进入别人的房子。如果你没有特别指定的话,你所做的操作都是针对你当前所在房子中的东西。至于你是否有权限使用(select)、搬动(update)或者拿走(delete)这些家具就看这个房子的主人有没有给你这样的权限了,或者你是整个大厦(DB)的老大(DBA)。alter session set schema可以用来代替synonyms。如果你想调用其他schema的对象(有权限的前提下),但并没有建synonym,同时又不想把其他schema名字放入代码中,就可以首先使用alter session set schema=<其他schema名字>。”