至于你是否有权限使用(select)、搬动(update)或者拿走(delete)这些家具就看这个房子的主人有没有给你这样的权限了,或者你是整个大厦(DB)的老大(DBA)。alter session set schema可以用来代替synonyms。如果你想调用其他schema的对象(有权限的前提下),但并没有建synonym,同时又不想把其他schema名字放入代码中,就可以首先使用alter session set schema=<其他schema名字>。
select
owner,table_name from all_tables where table_name = Upper('product')
select
owner,table_name from all_tables where table_name = Upper('product_detail')
其他参考资料:
user是控制权限的,而schema则是一个容器,非所有者如果需要访问这个容器下的对象,就需要在对象前面写上schema(owner)的名字,如果不想写而又没有创建synonym,此时可以通过alter session
set current_schema=schema_name来改变当前session的schema从而在访问对象时省去schema(owner);最终能否访问对象还是要看是否有访问这个对象的权限而和schema无关。
The schema (pronounced skee-ma) of a
database system is its structure described in a formal language supported by
the database management system (DBMS). In a relational database, the schema
defines the tables, the fields, relationships, views, indexes, packages,
procedures, functions, queues, triggers, types, sequences, materialized views,
synonyms, database links, directories, Java, XML schemas, and other elements.
schema: Collection of database objects,
including logical structures such as tables, views, sequences, stored
procedures, synonyms, indexes, clusters, and database links. A schema has the
name of the user who controls it.
Synonym(同义词):建立一个同义词可以排除一个对象名字的限制 如果你的数据库有多个用户,USER_A要访问USER_B的TABLE1,只能使用USER_B.TABLE1 建一个同义词abc指向USER_B.TABLE1,那你就可以select * from abc了,而且public的同义词会直接出现在所有用户的面前。