title: dynamic table name in select statement
body: <p>I have a series of history tables in an oracle 9 database. History_table_00 contains last months data, History_table_01 contains the month before, and History_table_02 the month before that. Next month, History_table_02 will automatically get renamed to history_table_03, history_table_01 renamed to history_table_02, history_table_00 renamed to history_table_01, and a new history_table_00 will be created to gather the newest history (I really hope I am making sense). </p>
  
  <p>Anyway, I need to write a select statement that will dynamically select all history tables. I am hoping this won't be too complicated because they all share the same name, just appended with sequential number so I can discover the table names with:</p>
  
  <pre><code>select table_name from all_tables where table_name like 'HISTORY_TABLE_%';
  </code></pre>
  
  <p>My standard query for each table is going to be:</p>
  
  <pre><code>select id, name, data_column_1, data_column_2 from history_table_%;
  </code></pre>
  
  <p>What do I have to do to accomplish the goal of writing a sql statement that will always select from all history tables without me needing to go in every month and add the new table? Thanks for anything you guys can provide.</p>