Summary of frequently use Unity Catalog and Spark SQL management commands, organized in a table.
Category | Command | Description | Example |
---|---|---|---|
Catalog Management | SHOW CATALOGS | Lists all available catalogs. | SHOW CATALOGS; |
Schema Management | SHOW SCHEMAS IN <catalog_name> | Lists schemas (databases) within a catalog. | SHOW SCHEMAS IN main; |
DESCRIBE SCHEMA <catalog_name>.<schema_name> | Provides metadata about a specific schema. | DESCRIBE SCHEMA main.default; | |
Table Management | SHOW TABLES IN <catalog_name>.<schema_name> | Lists all tables in a schema. | SHOW TABLES IN main.default; |
DESCRIBE TABLE <catalog_name>.<schema_name>.<table_name> | Displays metadata about a specific table. | DESCRIBE TABLE main.default.sales_data; | |
SHOW PARTITIONS <catalog_name>.<schema_name>.<table_name> | Lists partitions of a partitioned table. | SHOW PARTITIONS main.default.sales_data; | |
SHOW COLUMNS IN <catalog_name>.<schema_name>.<table_name> | Lists all columns of a table, including their data types. | SHOW COLUMNS IN main.default.sales_data; | |
DROP TABLE <catalog_name>.<schema_name>.<table_name> | Deletes a table from the catalog. | DROP TABLE main.default.sales_data; | |
Database Management | SHOW DATABASES | Lists all databases (schemas) in the environment. | SHOW DATABASES; |
DESCRIBE DATABASE <database_name> | Provides metadata about a specific database. | DESCRIBE DATABASE default; | |
Data Querying | SELECT * FROM <catalog_name>.<schema_name>.<table_name> | Queries data from a table. | SELECT * FROM main.default.sales_data WHERE region = 'West'; |
Table Creation | CREATE TABLE <catalog_name>.<schema_name>.<table_name> (<columns>) | Creates a managed table in Unity Catalog. | CREATE TABLE main.default.sales_data (id INT, region STRING, amount DOUBLE); |