0
我有这个plsql代码,它将为我提供名为CUSTOMERS的数据库中的所有表。现在我感到如何在此插入另一个循环。我想从这段代码中得到输出,并将它传递到下一个循环,我想要查询类似于Schema.customers中的select count(*);为每个模式。我的代码查询Oracle中的所有表格
DECLARE
--c_id customers.id%type;
c_name all_tables.table_name%type;
c_tabs all_tables.owner%type;
CURSOR c_tables is
SELECT table_name, owner FROM all_tables where table_name='CUSTOMERS';
BEGIN
OPEN c_tables;
LOOP
FETCH c_tables into c_name, c_tabs;
dbms_output.put_line(c_tabs || '.' || c_name);
EXIT WHEN c_tables%notfound;
END LOOP;
CLOSE c_tables;
END;
/
-------输出示例:------------
UMICH2.CUSTOMERS
TRINITYDC.CUSTOMERS
BUFFALO.CUSTOMERS
SNOW.CUSTOMERS
PULASKITECH.CUSTOMERS
RARITANVAL.CUSTOMERS
STMARYSCA.CUSTOMERS
[动态创建和在Oracle中执行SQL命令]可能重复(http://stackoverflow.com/questions/2284079/dynamically-creating -and-executed-sql-commands-in-oracle) – Bulat 2014-08-29 16:04:46
也http://stackoverflow.com/questions/22216805/executing-dynamic-sql-query-in-oracle – Bulat 2014-08-29 16:06:15