使用sql获取目标表字段

使用sql获取目标表字段
select
  owner, table_name, to_char(column_name) AS column_name
  from (select c.OWNER,
                c.TABLE_NAME,
                listagg(c.COLUMN_name || ' ' || case
                          when nvl(data_scale, 0) != 0 and data_type = 'NUMBER' then
                          data_type || '(' || data_precision || ',' || data_scale || ')'
                          when data_type = 'NUMBER' and data_precision is not null then
                          data_type || '(' || data_precision || ')'    
                          when data_type = 'NUMBER' and data_precision is null then
                          data_type 
                          when data_type = 'VARCHAR2' then
                          data_type || '(' || data_length || ')'    
                          when data_type = 'CHAR' then
                          data_type || '(' || data_length || ')'
                          when data_type = 'DATE' then
                          data_type
                        end,
                        ',') within
          group(
          order by column_id) AS column_name
          from sys.all_tab_columns   c
          where c.owner = '<<schema>>'
            and table_name like '<<table_name>>%'
          group by c.OWNER, c.TABLE_NAME);
posted @   feitiandamo  阅读(237)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
点击右上角即可分享
微信分享提示