oracl中有一个字段很多的表其中有些完全没有数据 或者是“”如何写sql语句查询是哪些字段下面没有数据或者空字符呢?
好困扰啊!
看了其他问答 多数都是知道自己特定要查询的字段 去查询
像这种完全不知道字段是否有数据时如何 查询
oracle 如何查询无数据的全部字段?
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- zoyation 2019-02-22 16:13关注
ORACLE11G:
步骤
1.用动态脚本生成sqlselect 'select field from(select field,null_count from (select ' || wm_concat('(select count (1) from YOUR_TABLE b where b.' || column_name || ' is not null and '|| column_name|| '<>'''')' || column_name) || ' from dual) t unpivot (null_count for field in (' || wm_concat(column_name) || ')) ) t where t.null_count=0;' from user_tab_columns where table_name = 'YOUR_TABLE';
2.执行sql
替换youer_table为你的表解决 2无用