Unity Catalog Setup

Prerequisites

Step 1: Create a Metastore

The metastore is the cloud-backed central repository for all Unity Catalog metadata.

-- Via SQL (in any workspace in the account)
CREATE METASTORE my_metastore
  PROVIDER_NAME aws  -- or 'azure', 'gcp'
  LOCATION 's3://my-bucket/metastore-root'  -- cloud storage path

Alternatively, use the Databricks account console (admin.databricks.com) under Admin → Metastores to create visually.

Step 2: Assign Metastore to Workspace

A workspace can use only one metastore. All workspaces assigned to the same metastore share catalogs and permissions.

-- Via account console or API
-- Associate the workspace with the metastore

Once assigned, run a test query to verify:

SELECT current_metastore();

Step 3: Create Catalogs and Schemas

Catalogs are top-level containers. Schemas organize tables within catalogs.

-- Create a catalog (requires account-level admin or owner role)
CREATE CATALOG finance_prod;

-- Create a schema within the catalog
CREATE SCHEMA finance_prod.transactions;

-- Create a table in the schema (3-level path)
CREATE TABLE finance_prod.transactions.orders (
  order_id INT,
  customer_id INT,
  order_date TIMESTAMP,
  amount DECIMAL(10, 2)
);

Step 4: Set Up External Locations and Storage Credentials

Required for external tables and volumes.

-- Create a storage credential (AWS example)
CREATE STORAGE CREDENTIAL s3_credentials
  PROVIDER amazon
  CREDENTIAL_PROVIDER_TYPE assume_role
  WITH (ROLE_ARN = 'arn:aws:iam::123456789012:role/UnityCatalogRole');

-- Create an external location tied to a storage credential
CREATE EXTERNAL LOCATION s3_data_lake
  URL 's3://my-data-bucket/external-data'
  WITH (STORAGE_CREDENTIAL = s3_credentials);

Step 5: Grant Permissions

Control who can access catalogs, schemas, and tables using the principle of least privilege.

-- Grant USE CATALOG to a group (enables browsing the catalog)
GRANT USE CATALOG ON CATALOG finance_prod TO `data-team@company.com`;

-- Grant USE SCHEMA to access a specific schema
GRANT USE SCHEMA ON SCHEMA finance_prod.transactions TO `data-team@company.com`;

-- Grant SELECT to read table data
GRANT SELECT ON TABLE finance_prod.transactions.orders TO `data-team@company.com`;

-- Grant MODIFY for write access
GRANT MODIFY ON TABLE finance_prod.transactions.orders TO `data-team@company.com`;

-- Grant ALL PRIVILEGES (full control, use sparingly)
GRANT ALL PRIVILEGES ON CATALOG finance_prod TO `admin-group@company.com`;

Step 6: View and Audit Permissions

-- Show all grants on a catalog
SHOW GRANTS ON CATALOG finance_prod;

-- Show all grants on a specific schema
SHOW GRANTS ON SCHEMA finance_prod.transactions;

-- Show grants for a specific principal
SHOW GRANTS ON SCHEMA finance_prod.transactions TO `data-team@company.com`;

-- View who has access to a table
SHOW GRANTS ON TABLE finance_prod.transactions.orders;

Best Practices