当前所在位置:珠峰网资料 >> 计算机 >> Oracle认证 >> 正文
Oracle数据库中四大应用服务之间的密切关系(二)
发布时间:2010/9/13 11:22:05 来源:www.xue.net 编辑:城市总裁吧
举例如下:

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

--上面这个查询就是将 schema 作为 user 的别名的依据。实际上在使用上,shcema 与 user 完全一样,没有什么区别,在出现 schema 名的地方也可以出现 user 名。

schema 和 user 一般是一致的,建立一个 user 后即可得到一个 schema,如:HR 用户建立后便有 HR 方案,接下来建立表、索引等数据库对象时,要指定其属于哪个 schema,也要指定其存放在哪个 tablespace 里。

也可以这样理解,schema 是数据库对象的逻辑归属和分类,而 tablespace 是数据库对象的物理和实际存放位置。

广告合作:400-664-0084 全国热线:400-664-0084
Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号
珠峰网 版权所有 All Rights Reserved