SELECT 'select '|| LISTAGG(column_name, ' , ') WITHIN GROUP (ORDER BY column_name) OVER (PARTITION BY TABLE_NAME) ||' from ' ||TABLE_NAME,TABLE_NAME,row_number() over(partition by TABLE_NAME order by table_name ) rn from ( select * FROM user_tab_cols where table_name in ('Tab1','Tab2','Tab3','Tab4') )
通过标号去重