Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to list all the user tables in Sybase along with their row count?

Tags:

sybase

I would like to return all the tables and its count next to it. what is the quickest way to go about it?

I know in Oracle, you can do something like below, but not sure about Sybase:

declare n number;
begin
   for rec in (select object_name from user_objects where object_type='TABLE')
   loop
     execute immediate 'select count(*) from '||rec.object_name into n;
     dbms_output.put_line (rec.object_name||':'||n);
   end loop;
end;
like image 919
Neerav Avatar asked Aug 12 '13 19:08

Neerav


1 Answers

Here is the Sybase sql that does the above:

select ob.name,st.rowcnt 
from sysobjects ob, systabstats st 
where ob.type="U"  
and st.id=ob.id 
order by ob.name
like image 140
Neerav Avatar answered Oct 01 '22 20:10

Neerav