模式与数据库、数据库中的表的关系

A schema is a collection of database objects (used by a user.).

Schema objects are the logical structures that directly refer to the database’s data.

user is a name defined in the database that can connect to and access objects.

Schemas and users help database administrators manage database security.

如果把database看作是一个仓库,仓库很多房间(schema),一个schema代表一个房间,table可以看作是每个房间中的储物柜,user是每个schema的主人,有操作数据库中每个房间的权利,就是说每个数据库映射的user有每个schema(房间)的钥匙。

SQL> Gruant dba to scott

SQL> create table test(name char(10));

Table created.

SQL> create table system.test(name char(10));

Table created.

SQL> insert into test values('scott');

1 row created.

SQL> insert into system.test values('system');

1 row created.

SQL> commit;

Commit complete.

SQL> conn system/manager

Connected.

SQL> select * from test;

NAME

----------

system

SQL> ALTER SESSION SET CURRENT_SCHEMA = scott; --改变用户缺省schema名

Session altered.

SQL> select * from test;

NAME

----------

scott

SQL> select owner ,table_name from dba_tables where table_name=upper('test');

OWNER TABLE_NAME

------------------------------ ------------------------------

SCOTT TEST

SYSTEM TEST

你可能感兴趣的:(模式与数据库、数据库中的表的关系)