{"id":10915,"date":"2015-08-24T16:05:06","date_gmt":"2015-08-24T21:05:06","guid":{"rendered":"http:\/\/jianmingli.com\/wp\/?p=10915"},"modified":"2015-08-24T16:11:53","modified_gmt":"2015-08-24T21:11:53","slug":"plsql-example-count-table-rows-in-a-schema","status":"publish","type":"post","link":"https:\/\/jianmingli.com\/wp\/?p=10915","title":{"rendered":"PL\/SQL Example: Count Table Rows in a Schema"},"content":{"rendered":"<pre lang=\"sql\">\r\n\r\ndeclare\r\n  cursor c1 is\r\n    select tname from tab;\r\n  tbl varchar2(64 char);\r\n  cnt number;\r\nbegin\r\n  dbms_output.put_line('Start... ');\r\n  open c1;\r\n  loop\r\n    begin\r\n      fetch c1 into tbl;\r\n      exit when c1%NOTFOUND;\r\n      execute immediate 'select count(*) c from ' || tbl\r\n        into cnt;\r\n      dbms_output.put_line('Table: ' || tbl || ' row count: ' || cnt);\r\n    exception\r\n      when others then\r\n      null;\r\n    end;\r\n  end loop;\r\n  close c1;\r\nend;\r\n\/\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>declare cursor c1 is select tname from tab; tbl varchar2(64 char); cnt number; begin dbms_output.put_line(&#8216;Start&#8230; &#8216;); open c1; loop begin fetch c1 into tbl; exit when c1%NOTFOUND; execute immediate &#8216;select count(*) c from &#8216; || tbl into cnt; dbms_output.put_line(&#8216;Table: &#8216; &hellip; <a href=\"https:\/\/jianmingli.com\/wp\/?p=10915\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[35,74],"tags":[584],"class_list":["post-10915","post","type-post","status-publish","format-standard","hentry","category-oracle","category-plsql","tag-plsql"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8cRUO-2Q3","_links":{"self":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/10915","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10915"}],"version-history":[{"count":3,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/10915\/revisions"}],"predecessor-version":[{"id":10918,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/10915\/revisions\/10918"}],"wp:attachment":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10915"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10915"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10915"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}