<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Query to know all tables and columns name in delta lake in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/query-to-know-all-tables-and-columns-name-in-delta-lake/m-p/27895#M19733</link>
    <description>&lt;P&gt;To view columns in a table, use SHOW COLUMNS.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;%sql
show columns in &amp;lt;schema_name&amp;gt;.&amp;lt;table_name&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;To show all the tables in a column, use following PySpark code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;%python
&amp;nbsp;
schema_name = "default"
tbl_columns = {}
&amp;nbsp;
# Get all tables in a schema
tables = spark.sql("show tables from {}".format(schema_name)).\
               select('tableName').\
               rdd.map(lambda x : x[0]).\
               collect()
&amp;nbsp;
&amp;nbsp;# Get all columns in each table
for table in tables:
  tbl_columns[table]=spark.sql("show columns from {}.{}".format(schema_name,table)).\
              select('col_name').\
              rdd.map(lambda x : x[0]).\
              collect()
&amp;nbsp;
print(tbl_columns) #print JSON&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 16 Feb 2022 23:05:45 GMT</pubDate>
    <dc:creator>AmanSehgal</dc:creator>
    <dc:date>2022-02-16T23:05:45Z</dc:date>
    <item>
      <title>Query to know all tables and columns name in delta lake</title>
      <link>https://community.databricks.com/t5/data-engineering/query-to-know-all-tables-and-columns-name-in-delta-lake/m-p/27894#M19732</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;​&lt;/P&gt;&lt;P&gt;Does anyone know how to write simple SQL query to get all tables and columns name. In oracle we do ,select * from all tab columns. Similarly in SQL server we do select * from information schema . columns.&lt;/P&gt;&lt;P&gt;​&lt;/P&gt;&lt;P&gt;Do we have something like this in databricks?&lt;/P&gt;&lt;P&gt;​&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 22:33:02 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/query-to-know-all-tables-and-columns-name-in-delta-lake/m-p/27894#M19732</guid>
      <dc:creator>sudhanshu1</dc:creator>
      <dc:date>2022-02-16T22:33:02Z</dc:date>
    </item>
    <item>
      <title>Re: Query to know all tables and columns name in delta lake</title>
      <link>https://community.databricks.com/t5/data-engineering/query-to-know-all-tables-and-columns-name-in-delta-lake/m-p/27895#M19733</link>
      <description>&lt;P&gt;To view columns in a table, use SHOW COLUMNS.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;%sql
show columns in &amp;lt;schema_name&amp;gt;.&amp;lt;table_name&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;To show all the tables in a column, use following PySpark code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;%python
&amp;nbsp;
schema_name = "default"
tbl_columns = {}
&amp;nbsp;
# Get all tables in a schema
tables = spark.sql("show tables from {}".format(schema_name)).\
               select('tableName').\
               rdd.map(lambda x : x[0]).\
               collect()
&amp;nbsp;
&amp;nbsp;# Get all columns in each table
for table in tables:
  tbl_columns[table]=spark.sql("show columns from {}.{}".format(schema_name,table)).\
              select('col_name').\
              rdd.map(lambda x : x[0]).\
              collect()
&amp;nbsp;
print(tbl_columns) #print JSON&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 23:05:45 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/query-to-know-all-tables-and-columns-name-in-delta-lake/m-p/27895#M19733</guid>
      <dc:creator>AmanSehgal</dc:creator>
      <dc:date>2022-02-16T23:05:45Z</dc:date>
    </item>
  </channel>
</rss>

