受限模式

本文介绍如何通过两种方式设置数据库为受限模式,即使用STARTUP RESTRICT命令启动数据库或使用ALTER SYSTEM ENABLE RESTRICTED SESSION命令。受限模式下,仅授权用户可访问数据库。

今天看书偶尔看到以受限模式(restrict)打开资料库,或者把数据库处于受限模式,这样可以很方便地在特殊情况对数据库进行操作。所谓受限就是只有拥有权限的人才能访问数据库。

使数据库处于受限模式,有以下二种方法

1) STARTUP RESTRICT

2) ALTER SYSTEM ENABLE RESTRICTED SESSION;

对于第二种情况,只能使发布命令后的登陆生效,因此如果对于这种情况,一般会杀掉前面已经登陆的进程!

[@more@]

SYS@HUIYI>shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@HUIYI>startup restrict;
ORACLE instance started.

Total System Global Area  135338868 bytes
Fixed Size                   453492 bytes
Variable Size             113246208 bytes
Database Buffers           20971520 bytes
Redo Buffers                 667648 bytes
Database mounted.
Database opened.

D:>sqlplus scott/tiger

SQL*Plus: Release 9.2.0.1.0 - Production on Mon Mar 26 20:13:08 2007

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

ERROR:
ORA-01035: ORACLE only available to users with RESTRICTED SESSION privilege

-- 给SCOTT赋权
SYS@HUIYI>grant restricted session to scott;

Grant succeeded.

D:>sqlplus scott/tiger

SQL*Plus: Release 9.2.0.1.0 - Production on Mon Mar 26 20:19:10 2007

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.


Connected to:
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production

SCOTT@HUIYI>select * from session_privs where privilege like 'RES%';

PRIVILEGE
----------------------------------------
RESTRICTED SESSION



SYS@HUIYI>startup force;
ORACLE instance started.

Total System Global Area  135338868 bytes
Fixed Size                   453492 bytes
Variable Size             113246208 bytes
Database Buffers           20971520 bytes
Redo Buffers                 667648 bytes
Database mounted.
Database opened.
SYS@HUIYI>revoke restricted session from scott;

Revoke succeeded.

SYS@HUIYI>alter system enable restricted session;

System altered.

D:>sqlplus scott/tiger

SQL*Plus: Release 9.2.0.1.0 - Production on Mon Mar 26 20:35:59 2007

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

ERROR:
ORA-01035: ORACLE only available to users with RESTRICTED SESSION privilege

-- 取消受限
SYS@HUIYI>alter system disable restricted session;

System altered.

D:>sqlplus scott/tiger

SQL*Plus: Release 9.2.0.1.0 - Production on Mon Mar 26 20:37:51 2007

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.


Connected to:
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production

SCOTT@HUIYI>

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/8799875/viewspace-906977/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/8799875/viewspace-906977/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值