我是靠谱客的博主 受伤发夹,最近开发中收集的这篇文章主要介绍[转] oracle限制用户在某个时间段内禁止登录数据库,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

[size=small]原文: http://blog.itpub.net/29371470/viewspace-1081319/
[oracle@rhel ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.5.0 - Production on Sat Feb 8 12:51:15 2014
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create user lsq identified by lsq;
User created.
SQL> grant connect, resource to lsq;
Grant succeeded.
SQL> conn lsq/lsq
Connected.
SQL> disc
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> conn / as sysdba
Connected.
SQL> CREATE OR REPLACE TRIGGER limit_connection
2 AFTER LOGON ON DATABASE
3 BEGIN
4 IF USER = 'LSQ' THEN
5 IF to_number(TO_CHAR (SYSDATE, 'hh24')) BETWEEN 8 AND 22
6 THEN
7 RAISE_APPLICATION_ERROR(-20998,' Dear user '||USER||'! You can''t login between 08 and 22');
8 END IF;
9 END IF;
10 END limit_connection;
11 /
Trigger created.
SQL> select to_char(sysdate,'hh24') from dual;
TO
--
12
SQL> conn lsq/lsq
ERROR:
ORA-00604: error occurred at recursive SQL level 1
ORA-20998: Dear user LSQ! You can't login between 08 and 22
ORA-06512: at line 5
Warning: You are no longer connected to ORACLE.[/size]

最后

以上就是受伤发夹为你收集整理的[转] oracle限制用户在某个时间段内禁止登录数据库的全部内容,希望文章能够帮你解决[转] oracle限制用户在某个时间段内禁止登录数据库所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(89)

评论列表共有 0 条评论

立即
投稿
返回
顶部