--动态sql拼接你的表名: sql_str:='select * from table'||to_char(sysdate,'yyyymm'); execute immediate sql_str;
执行报错? 能不能详细点把VIEW的一并写出来?
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')
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')
给你最简单的sql:select a.table_name from user_tables a where upper(a.table_name) = 'TABLE' || to_char(sysdate,'yyyymm'); 注:user_tables是任何版本的oracle都自带的一张系统视图。
sql_str:='select * from table'||to_char(sysdate,'yyyymm');
execute immediate sql_str;
能不能详细点把VIEW的一并写出来?
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')
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')
注:user_tables是任何版本的oracle都自带的一张系统视图。