2

I want to do aggregations on the result of

SHOW TABLES FROM databasename

Or create a new table with the result like

CREATE TABLE database.new_table AS (

     SHOW TABLES FROM database
);

But I'm getting multiple different errors if I try to do anything else with SHOW TABLES.

Is there another way of doing anything with the result of SHOW TABLES or another way creating a table with all the column names in a database? I have previously worked with Teradata where it's quite easy.

Edit: I only have access to Databricks SQL Analytics. So can only write in pure SQL.

robin_xxx
  • 21
  • 2

1 Answers1

0

Another way of doing it:

spark.sql("use " + databasename)

df = spark.sql("show tables")

df.write.saveAsTable('databasename.new_table')

binar
  • 14
  • 2
  • I forgot to mention that I only have access to Databricks SQL Analytics. Therefore, I can only write in pure SQL. – robin_xxx Jan 07 '22 at 08:40