SQL server 2000
declare @ExecSql varchar(500)set @ExecSql='exec sp_addlinkedserver ''orab'',''oracle'',''msdaora'',''stat'''
exec(@ExecSql)
set @ExecSql='exec sp_addlinkedsrvlogin ''orab'',''false'',''sa'',''bss'',''bss'''
exec(@ExecSql)--表名product_hm4
select * from orab..BSS.USER_TABLES  
--消息 7314,级别 16,状态 1,第 1 行
--OLE DB 提供程序 'orab' 不包含表 '"BSS"."USER_TABLES"'。该表可能不存在,或当前用户没有使用该表的权限。set @ExecSql='exec sp_dropserver ''orab'',''droplogins'''
exec(@ExecSql)在SQL PLUS 中确可以查询USER_TABLES  , SQL中提示表可能不存在,这是为什么?如何解决?

解决方案 »

  1.   

    如果权限不够,在SQL PLUS里应该也无法查询表USER_TABLES吧
      

  2.   

    所谓USER_TABLES,属于ORACLE内部数据字典视图。你程序连接ORACLE是以BSS用户登录ORACLE数据库的吗?
    如果是,去掉用户名前缀试试
      

  3.   

    user_table是sys用户的视图,不属于你的普通用户。
    select * from user_tables
      

  4.   


    select * from orab...USER_TABLES 
    select * from orab..SYS.USER_TABLES 这两种方法都不行,
    select * from user_tables 这样查询的是SQL SERVER ,
      

  5.   

    换一种方法咯。
    SELECT * FROM SYS.dba_tables
    where owner='BBS' and table_name=?;类似这样的。当然BBS首先需要有dba_tables的select权限。
      

  6.   

    还是一样的,在SQL Plus下可以查询,
    在SQL SERVER里提示“该表可能不存在,或当前用户没有使用该表的权限”,
    连接是没有问题的,select top 10 * from orab..BSS.PRODUCT_HM4,显示了10条记录
      

  7.   

    看来,这透明网关就认定了,内部数据字典视图识别不了
    可否考虑把BBS用户的所有表名,存在一张物理表里。
    create table mytables as select table_name from user_tables;然后select * from mytables;
    当然,这样维护起来麻烦些,新建表后,需要向该表中插入数据。手工维护