declare
cursor t is select * from mao.tabs where rownum<10;
cursor c(t_name tabs.table_name%type) is select * from mao.cols where cols.table_name=t_name;
t_r tabs%rowtype;
c_r cols%rowtype;
begin
for t in (select * from mao.tabs where rownum<10) loop
dbms_output.put_line(t.owner||' '||t.table_name||': ');
dbms_output.put_line('-------');
for c in(select * from mao.cols where table_name=t.table_name) loop
dbms_output.put_line(c.column_name);
end loop;
dbms_output.put_line('-------');
end loop;
end;[@more@]declare
cursor t is select * from mao.tabs where rownum<10;
cursor c(t_name tabs.table_name%type) is select * from mao.cols where cols.table_name=t_name;
t_r tabs%rowtype;
c_r cols%rowtype;
begin
open t;
loop
fetch t into t_r;
exit when t%notfound;
dbms_output.put_line(t_r.table_name||':');
dbms_output.put_line('-----');
open c(t_r.table_name);
loop
fetch c into c_r;
exit when c%notfound;
dbms_output.put_line('Colum name:'||c_r.column_name);
end loop;
close c;
dbms_output.put_line('-----');
end loop;
close t;
end;
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/9907339/viewspace-1054230/
,如需转载,请注明出处,否则将追究法律责任。