Azure Databricks中查找含XYZ列名报错:找不到information_schema.columns
在Azure Databricks中搜索含指定关键词的列名
错误原因
Azure Databricks的SQL环境中,不能直接引用information_schema.columns,需要指定默认的catalog(spark_catalog)才能访问元数据视图。
正确的SQL语句
要搜索所有包含“XYZ”的列名,执行以下SQL:
SELECT table_name, column_name FROM spark_catalog.information_schema.columns WHERE column_name LIKE '%XYZ%' ORDER BY table_name, column_name;
可选扩展:指定特定数据库查询
如果只想搜索某个数据库(比如名为my_db的库)中的列,可添加table_catalog和table_schema条件:
SELECT table_name, column_name FROM spark_catalog.information_schema.columns WHERE table_schema = 'my_db' AND column_name LIKE '%XYZ%' ORDER BY table_name, column_name;
内容的提问来源于stack exchange,提问作者QuicKick
相关产品推荐
相关产品推荐

