Create CSV version 1 (not using PL/SQL but still creates a CSV file) with help from here
set colsep ,
set pagesize 0
set trimspool on
set headsep off
set linesize 100
set numw 10
spool myfile.csv
select table_name,count(column_name) as cnt
from all_tab_columns where owner ='HR'
group by table_name);
Version 2 with a bit PL/SQL
set serveroutput on
begin
for c in (select table_name,count(column_name) as cnt
from all_tab_columns where owner ='HR' group by table_name)
loop
dbms_output.put_line(c.table_name||';'||c.cnt);
end loop;
end;
/
Version 3 would be using the utl_file package if you want the file server side but I was now assuming you run it in SQLplus or SQLdeveloper.