现在有几张表
table201009
table201010
table201011希望做一个视图,根据当前月份读取表

解决方案 »

  1.   

    --动态sql拼接你的表名:
    sql_str:='select * from table'||to_char(sysdate,'yyyymm');
    execute immediate sql_str;
      

  2.   

    执行报错?
    能不能详细点把VIEW的一并写出来?
      

  3.   

    select 字段列表 from (
    select t.*,'201009' table_month from table201009 t
    union all
    select t1.*,'201010' table_month from table201009 t1
    union all
    select t2.*,'201011' table_month from table201009 t2)
    where table_month=to_char(sysdate,'yyyymm')
      

  4.   

    select 字段列表 from (
    select t.*,'201009' table_month from table201009 t
    union all
    select t1.*,'201010' table_month from table201010 t1
    union all
    select t2.*,'201011' table_month from table201011 t2)
    where table_month=to_char(sysdate,'yyyymm')
      

  5.   

    给你最简单的sql:select a.table_name from user_tables a where upper(a.table_name) = 'TABLE' || to_char(sysdate,'yyyymm');
    注:user_tables是任何版本的oracle都自带的一张系统视图。