无法弄清楚PL SQL代码中的错误和解决方案

时间:2013-05-24 08:29:51

标签: oracle plsql

我提供了此代码,用于获取一个数据库中所有模式的所有表描述。我在网上搜索并想出了下面的代码。我无法弄清楚错误。

任何可以帮助解决此错误的人或者为我提供问题的替代方案

SQL>  Begin
  2    For q in (select distinct owner from dba_objects)
  3    loop
  4   for r in (select table_name, owner from all_tables where owner = 'q.owner')
  5   loop
  6    dbms_output.put_Line('table '||r.table_name);
  7    execute immediate 'desc ' || r.table_name
  8    end loop;
  9    end loop;
 10    end;
 11    /

end loop;
 *

ERROR at line 8:
ORA-06550: line 8, column 3:
PLS-00103: Encountered the symbol "END" when expecting one of the following:
. ( * @ % & = - + ; < / > at in is mod remainder not rem
return returning <an exponent (**)> <> or != or ~= >= <= <>
and or like like2 like4 likec between into using || bulk
member submultiset
The symbol ";" was substituted for "END" to continue.

2 个答案:

答案 0 :(得分:1)

尝试:

select   *
from     all_tab_columns
where    owner = 'MY_OWNER_NAME'
order by owner,
         table_name,
         column_id;

使用参考here选择您感兴趣的列。例如,如果您只对字符数据类型感兴趣,则可以添加其他谓词。

答案 1 :(得分:0)

第7行:execute immediate 'desc ' || r.table_name

您忘了放;