How do I get a list of the tables that I personally created?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2022 02:17 PM
I know that I can get a list of all of the table names in a given 'database' by using (if the 'database' was named "scratch"): show tables from scratch
How do I get a list just like that, but that only lists the tables that I created?
- Labels:
-
Table Names
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2022 07:25 AM
Without Unity Catalog using table history :
- Call "SHOW TABLES FROM db_name" to collect all tables names
- Loop on tables identifying the table creator using the next command : spark.sql('DESCRIBE HISTORY db_name.table_name').where('operation like "CREATE TABLE%"').select('userName').first()['userName']
- Filter the result obtained in p.2 to obtain the target list of tables
Without Unity Catalog using owner field :
- Enable table access control for a cluster (https://docs.databricks.com/security/access-control/table-acls/table-acl.html)
- Set owner for each table that you need : ALTER TABLE db_name.my_table_name OWNER TO `abc@gmail.com`
- Call "SHOW TABLES FROM db_name" to collect all tables names
- Loop on tables identifying the table owner spark.sql('DESCRIBE EXTENDED db_name.table_name').filter('col_name = "Owner" and data_type = "abc@gmail.com"')
- Filter the result obtained in p.4 to obtain the target list of tables
With Unity Catalog tables, you can use created_by or table_owner column from information_schema.tables :
SELECT *
FROM my_unity_catalog_name.information_schema.tables
WHERE created_by LIKE '%my_username_name_part%'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2022 05:05 AM
Hi @Barb Krienke
Hope all is well! Just wanted to check in if you were able to resolve your issue and would you be happy to share the solution or mark an answer as best? Else please let us know if you need more help.
We'd love to hear from you.
Thanks!

