Views and Temp views

Data Management in Databricks

Smriti Mishra

Founder, NordData Insight

First look at views

  • A view saves a query for reuse as a table
  • Views are persistent
  • Remain available until deleted

Cartoon image of a recipe book with the ingredients required for a meal infront

Data Management in Databricks

View syntax

  • CREATE VIEW or CREATE OR REPLACE VIEW create/update views.
  • Useful for dashboards, reports, and consistent query results.

 

-- Create a view to get recipes with a preparation time of 30 minutes or less

CREATE VIEW QuickRecipes AS
SELECT recipe_id, recipe_name, ingredients, preparation_time
FROM recipes
WHERE preparation_time <= 30;
Data Management in Databricks

Temp views

  • Temp views are temporary and last only for the current session
  • Automatically erased when the session ends
  • Created using CREATE OR REPLACE TEMP VIEW
  • Ideal for quick analysis, staging, or exploratory tasks

Image of a person writing on a chalkboard

Data Management in Databricks

Benefits of views

Cartoon image of a piggy bank being deposited with clocks

  • Ideal for frequently accessed data
    • reusable charts, reports, or logic
  • Ensures consistent data across users and saves time
  • Simplifies collaboration with shared data logic
Data Management in Databricks

Benefits of temp views

  • Ideal for quick tasks
  • Flexible tools for staging/transformation
  • Auto-delete at session end
    • Reduce database clutter

Cartoon image of a screen showing different tools

Data Management in Databricks

Summary

  • Views offer persistent, reusable outputs
  • Temp views support single-session tasks
  • Effective use leads to:
    • Streamlined workflows
    • Enhanced collaboration
    • Optimized performance

Cartoon image showing three people working together in a streamlined flow

Data Management in Databricks

Let's practice!

Data Management in Databricks

Preparing Video For Download...