以下内容可用于分别显示当前模式或指定模式中的表:
show tables;
show tables in my_schema;
此处记录如下:https : //docs.databricks.com/spark/latest/spark-sql/language-manual/show-tables.html
有没有办法显示所有数据库中的所有表?
Databricks / Spark中是否有元数据表(类似于Oracle中的all_或dba_表或MySql中的information_schema)?有没有办法对Databricks中的数据库对象进行更具体的查询?像这样:
select * from i_dont_know_what where lower(table_name) like '%gold%' and schema = 'myschema';
您不能在数据块上使用Spark目录API吗?请尝试这个-
val tuples: Map[String, String] = spark.catalog.listDatabases().collect().flatMap(db =>
spark.catalog.listTables(db.name).collect().map(x => (db.name, x.name))
).toMap
看起来它先提取所有数据然后进行过滤。我目前正在用Java做某事。我希望有一种方法可以在sql中执行此操作。
这里没有表达式可以从数据库中提取数据。我们只是提取元数据
@Som能否用Python提供相同的代码?