使用Sql Navigator时出错

时间:2017-10-05 02:08:50

标签: sql oracle oracle-sqldeveloper sql-navigator

使用工具Sql Navigator 6.2.1时出错: 我在Sql Navigator中运行命令它警告错误:“ORA-01031:权限不足 ORA-06512:在“SYS.DBMS_UTILITY”,第140行 ORA-06512:第6行“

desc com.zsdddept;

com.zsdddept是表格 当我运行select命令时没有错误,单击表名称显示Sql Navigator中的表的属性无操作。

但我在Oracle Sql开发人员(同一用户)中运行以上命令结果没有错误并显示描述字段。

是什么原因?

由于

2 个答案:

答案 0 :(得分:0)

SQL Navigator执行SQL * Plus命令的自定义SQL模拟。 SQL Developer您自己的自定义SQL模拟SQL * Plus命令。 授予执行SYS.DBMS_UTILITY包的权利。

grant execute on SYS.DBMS_UTILITY to <username>;

示例1 desc DEPT在SQLNavigator 6.7中运行

select /*+ ALL_ROWS */ column_name,data_type,nullable,data_length,NVL(data_precision,-99),NVL(data_scale,-99),char_used, char_length 
 from sys.all_tab_columns where owner='SCOTT' and table_name='DEPT' order by column_id

Name                           Data Type                     
------------------------------ ------------------------------
DEPTNO                         NUMBER(2,0)           NOT NULL
DNAME                          VARCHAR2(14 BYTE)
LOC                            VARCHAR2(13 BYTE)

示例2 desc DEPT在SQL Developer v4.1中运行

select t.column_name "Name", 
                            decode(t.nullable,'Y',null,'NOT NULL') "Null",
                            decode(t.data_type_mod, null, '', t.data_type_mod ||' OF ')|| 
                            (CASE WHEN ( t.data_type_owner = UPPER(t.owner) OR t.data_type_owner is NULL )
                                  THEN ''
                                  ELSE t.data_type_owner ||'.' 
                             END ) || 
                            UPPER(t.data_type)||  
                            case when (   t.data_type='VARCHAR' 
                                       OR t.data_type = 'VARCHAR2' 
                                       OR t.data_type ='RAW' 
                                       OR t.data_type='CHAR') AND (
                                       t.data_length <> 0 AND 
                                       nvl(t.data_length,-1) <> -1)        then 
                                       case when(t.char_used ='C' and 'BYTE' =(select value from nls_session_parameters where PARAMETER='NLS_LENGTH_SEMANTICS')) then '(' || t.char_length || ' CHAR)'
                                            when(t.char_used ='B' and 'CHAR' =(select value from nls_session_parameters where PARAMETER='NLS_LENGTH_SEMANTICS')) then '(' || t.data_length || ' BYTE)'
                                            when(t.char_used ='C' and 'CHAR' =(select value from nls_session_parameters where PARAMETER='NLS_LENGTH_SEMANTICS')) then '(' || t.char_length || ')'
                                            when(t.char_used ='B' and 'BYTE' =(select value from nls_session_parameters where PARAMETER='NLS_LENGTH_SEMANTICS')) then '(' || t.data_length || ')'
                                            else '(' || t.data_length || ' BYTE)' 
                                       end    
                                 when (t.data_type='NVARCHAR2' OR t.data_type='NCHAR') then  
                                 '(' || t.data_length/2 || ')'   
                                 when (t.data_type like 'TIMESTAMP%' OR t.data_type like 'INTERVAL DAY%' OR t.data_type like 'INTERVAL YEAR%' OR t.data_type = 'DATE' OR
                                  (t.data_type = 'NUMBER' AND ((t.data_precision = 0) OR NVL (t.data_precision,-1) = -1) AND  nvl (t.data_scale,-1) = -1)) then
                                  '' 
                                 when ((t.data_type = 'NUMBER' AND NVL (t.data_precision,-1) = -1) AND (t.data_scale = 0)) then
                                  '(38)' 
                                 when ((t.data_type = 'NUMBER' AND NVL (t.data_precision,-1) = -1) AND (nvl (t.data_scale,-1) != -1)) then
                                  '(38,'|| t.data_scale ||')' 
                                 when ( t.data_type='BINARY_FLOAT' or t.data_type='BINARY_DOUBLE'   ) then
                                    ''
                                when (t.data_precision is NULL AND t.data_scale IS NULL ) then 
                                ''
                                when (t.data_scale  = 0 OR nvl(t.data_scale,-1) = -1) then
                                  '('|| t.data_precision ||')'
                                when (t.data_precision  != 0 AND t.data_scale  != 0 ) then
                                    '('|| t.data_precision ||',' ||t.data_scale ||')'     
                            end "Type"   
                            from sys.all_tab_columns t, sys.all_col_comments c
                             where t.column_name = c.column_name and c.owner = t.owner and c.table_name = t.table_name and
                              UPPER(t.owner) = UPPER(sys_context('USERENV', 'CURRENT_USER')) and t.table_name = :2 order by t.column_id


Name   Null     Type         
------ -------- ------------ 
DEPTNO NOT NULL NUMBER(2)    
DNAME           VARCHAR2(14) 
LOC             VARCHAR2(13) 

在sql缓存中,这是过程调用。

 declare
       l_schema      varchar2(128);
       l_part1       varchar2(128);
       l_part2       varchar2(128);
       l_dblink      varchar2(128);
       l_part1_type  number;
       l_objid       number;
    begin
     DBMS_UTILITY.NAME_RESOLVE ( 
       name          => :obj_name, 
       context       => 2,  -- interested in dba_ views only; 0 doesn't work in 10g -- bug 19528375
       schema        => l_schema,  
       part1         => l_part1, 
       part2         => l_part2,
       dblink        => l_dblink, 
       part1_type    => l_part1_type, 
       object_number => l_objid );
    end;

inv_restricted_object异常;   pragma exception_init(inv_restricted_object,-24239);

在SYS.DBMS_UTILITY

中处理异常时,在第140行上发表评论

 /*
   * Option flags supported by invalidate.
   *   inv_error_on_restrictions - The invalidate routine imposes various
   *   restrictions on the objects that can be invalidated. For example,
   *   the object specified by p_object_id cannot be a table. By default,
   *   invalidate quietly returns on these conditions (and does not raise
   *   an exception). If the caller sets this flag, the exception
   *   inv_restricted_object is raised.
   */
  inv_error_on_restrictions constant pls_integer := 1;

答案 1 :(得分:0)

desc命令不是SQL标准。 desc是sqlplus命令。 SQL Developer运行一个大的SQL查询和sql navigator一个简单的SQL查询。 SQLNavigator®forOracle V6.2.1不支持ORACLE 11.2版。

SQLNavigator®forOracle V 6.2.1发行说明2009年9月发行说明。

Oracle Database 11g第2版(11.2.0.1)2010年4月2日

您需要购买并安装最新版本的SQL Navigator或使用免费版本的sqlplus或Oracle SQL Developer。