sql - Loop through multiple tables to execute same query -


I have a database in which a table is created for the log process examples per day tables are labeled MESSAGE_LOG_YYYYMMDD

Currently I want to index the same QUERY against all those tables, I wrote down the PL / SQL but got stuck on line 10. How can I successfully execute SQL statements against all tables?

  Select DECLARE CURSOR all_tables from WHOE TABLE_NAME from all_ tables like 'MESSAGE_LOG_2%' ORDER by TABLE_NAME; TABLE msglog.TABLE_NAME from LOOP SELECT count (*) in all_tables for masGLog; End loop; End; Basically, inside your loop, create a string.  

Represent the query that you want to run, and use dynamic SQL to run the query.

To do anything useful, you probably want to insert the archive into a temporary table, then select the order by date descending.

Comments