Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4043175
  • 博文数量: 536
  • 博客积分: 10470
  • 博客等级: 上将
  • 技术积分: 4825
  • 用 户 组: 普通用户
  • 注册时间: 2006-05-26 14:08
文章分类

全部博文(536)

文章存档

2024年(3)

2021年(1)

2019年(1)

2017年(1)

2016年(2)

2013年(2)

2012年(10)

2011年(43)

2010年(10)

2009年(17)

2008年(121)

2007年(252)

2006年(73)

分类: Oracle

2008-07-02 14:52:00

My Question?
==============

SQL> select * from v$version;

BANNER
------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 -
Prod

PL/SQL Release 10.2.0.1.0 - Production
CORE    10.2.0.1.0      Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production

SQL> show user;
USER is "IGS_DST"

SQL> desc igs_dst.tab
 Name                          Null?    Type
 ----------------------------- -------- --------------------
 TNAME                         NOT NULL VARCHAR2(30)
 TABTYPE                                VARCHAR2(7)
 CLUSTERID                              NUMBER

SQL> select * from igs_dst.tab;
select * from igs_dst.tab
                      *
ERROR at line 1:
ORA-00942: table or view does not exist

===============
Answer: DESC时如果指定了方案限定词时是查找用户的表,视图,私有同义词或者公有同义词; 而SELECT的时候,如果指定了方案限定词,不会去查找公有同义词,所以才有这样的差别

===============
Select TAB view define in Oracle:

SQL> select text from sys.all_views where owner='SYS' and view_name ='TAB';

TEXT
------------------------------------------------------------
select o.name,
      decode(o.type#, 2, 'TABLE', 3, 'CLUSTER',
             4, 'VIEW', 5, 'SYNONYM'), t.tab#
  from  sys.tab$ t, sys.obj$ o
  where o.owner# = userenv('SCHEMAID')
  and o.type# >=2
  and o.type# <=5
  and o.linkname is null
  and o.obj# = t.obj# (+)

SQL> select userenv('SCHEMAID') from dual;

USERENV('SCHEMAID')
-------------------
                507

==================
SQL> create table aa(a int);

Table created.

SQL> create synonym syn_aa for aa;

Synonym created.

SQL> desc igs_dst.syn_aa;
 Name                          Null?    Type
 ----------------------------- -------- --------------------
 A                                      NUMBER(38)

SQL> select * from igs_dst.syn_aa;

no rows selected

==================
SQL> drop synonym syn_aa;

Synonym dropped.

SQL> create public synonym syn_aa for aa;

Synonym created.

SQL> desc igs_dst.syn_aa;
 Name                          Null?    Type
 ----------------------------- -------- --------------------
 A                                      NUMBER(38)

SQL> select * from igs_dst.syn_aa;
select * from igs_dst.syn_aa
                      *
ERROR at line 1:
ORA-00942: table or view does not exist

More Info See: http://vecentli.itpub.net/post/14011/66066
阅读(2402) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~