Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1693428
  • 博文数量: 136
  • 博客积分: 10021
  • 博客等级: 上将
  • 技术积分: 3261
  • 用 户 组: 普通用户
  • 注册时间: 2007-01-22 11:26
文章分类

全部博文(136)

文章存档

2010年(1)

2009年(26)

2008年(109)

我的朋友

分类: Oracle

2008-05-16 15:05:54

3月碰到一个数据库对象以小写形式存储的问题。今天又碰到了一次,不过这次是用户名用小写的方式建的。记录一下,作为上一篇的例子:
 
通过查询用户视图,可以看到有一个小写的用户“hbjb_kf”,同时还有一个同名的大写用户:

 

SQL> select username, user_id, default_tablespace from dba_users;

 

USERNAME        USER_ID DEFAULT_TABLESPACE

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

hbjb_kf              75 TP_HBJB_KF

HBJB_KF             136 TP_HBJB_KF

...

 

已选择97行。

 

SQL>

 

猜测可能是开发人员创建用户的时候,不小心建了个小写的用户,然后又创建了一个大写的用户。因为小写的用户使用起来很不方便,除非特殊情况,没有人会这样建。登录进去看看:

 

C:\Documents and Settings\yuechaotian>sqlplus

 

SQL*Plus: Release 9.2.0.1.0 - Production on 星期五 5 16 11:34:03 2008

 

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

 

请输入用户名:  "hbjb_kf"/mypassword@s46

ERROR:

ORA-01017: invalid username/password; logon denied

 

 

请输入用户名:  sys/superpassword@s46 as sysdba

 

连接到:

Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production

With the Partitioning, OLAP and Oracle Data Mining options

JServer Release 9.2.0.8.0 - Production

 

SQL> alter user "hbjb_kf" identified by mypassword;

 

用户已更改。

 

SQL> conn "hbjb_kf"/mypassword@s46

已连接。

SQL> show user

USER "hbjb_kf"

SQL> select count(*) from user_objects;

 

  COUNT(*)

----------

         0

 

SQL> conn hbjb_kf/mypassword@s46

已连接。

SQL> show user

USER "HBJB_KF"

SQL> select count(*) from user_objects;

 

  COUNT(*)

----------

      1650

 
该用户下没有对象,那么基本可以判断这个用户“hbjb_kf”是无用的。
 
这个用户是怎么创建的呢?我们可以再现一下:

 

SQL> create user "yuechaotian" identified by test;

 

用户已创建

 

SQL> grant connect,resource to "yuechaotian";

 

授权成功。

 

SQL> conn yuechaotian/test@s46;

ERROR:

ORA-01017: invalid username/password; logon denied

 

 

SQL> conn "yuechaotian"/test@s46;

已连接。

SQL> show user

USER "yuechaotian"

SQL>

 
但是经测试,用户的密码是不区分大小写的:

 

-- 1. 普通用户

SQL> alter user "yuechaotian" identified by "TeSt";

 

用户已更改。

 

SQL> conn "yuechaotian"/test@s46

已连接。

SQL> conn "yuechaotian"/"test"@s46

已连接。

SQL> conn "yuechaotian"/"tedsfdsfst"@s46

ERROR:

ORA-01017: invalid username/password; logon denied

 

 

警告: 您不再连接到 ORACLE

SQL> conn "yuechaotian"/"nopassword"@s46

ERROR:

ORA-01017: invalid username/password; logon denied

 

 

SQL> conn "yuechaotian"/"TEST"@s46

已连接。

SQL>

 

-- 2. 超级用户

SQL> conn sys/superpassword@s46 as sysdba
已连接。
SQL> show user
USER 为"SYS"
SQL> alter user sys identified by "Superpass";

用户已更改。

SQL> conn sys/superpassword@s46 as sysdba
ERROR:
ORA-01031: insufficient privileges


SQL> conn sys/superpass@s46 as sysdba
已连接。
SQL> conn sys/"Superpass"@s46 as sysdba
已连接。
SQL>

阅读(1817) | 评论(2) | 转发(0) |
给主人留下些什么吧!~~

yaoronghui20082008-06-18 21:39:27

你分析的很对,很细致把很多可能的方式都想到了。向你学习

chinaunix网友2008-05-25 11:08:21

要想删除用户"hbjb_kf",需要用 drop user "hbjb_kf"; 而不是 drop user hbjb_kf; -- 这将删除用户"HBJB_KF"