我想在ORACLE-SQL Developer中创建一个查询,它可以实时返回查询中指定的表及其计数/行数。
理想情况下,输出看起来像;
| Schema.Table | Count |
| abc.123 | 1000 |
| def.345 | 1223 | etc.
到目前为止,我有一个使用dba_tables的基本查询;
SELECT OWNER ||'.'|| table_name as "Schema.Tablename",
num_rows as "Number of Rows"
FROM dba_tables
WHERE
table_name = '123' and OWNER = 'abc'
or table_name = '345' and OWNER = 'def'
但是,我希望能够在实时中查询查询,因此我不想使用dba_tables或num_rows。
有人对此任务有任何提示或建议吗?
答案 0 :(得分:0)
如果您明确列出了表,那么只需使用表格编写查询:
SELECT 'abc.123' as table_name, count(*) as cnt
FROM abc.123
UNION ALL
SELECT 'def.345' as table_name, count(*) as cnt
FROM def.345;
这比PL / SQL循环和动态SQL简单得多。