SQL Editor & SQL Warehouses

Databricks · Databricks SQL & BI

Theory

Databricks SQL is the analytics side of the platform. You write queries in the SQL Editor and run them on a SQL warehouse, a compute resource built only for SQL. Warehouses come in serverless, pro and classic types. Serverless starts in seconds, scales automatically and is what Databricks recommends; pro and classic run in your cloud account. All of them use the Photon engine. A warehouse has a size (the cluster size, from 2X-Small upward), a scaling range for concurrency, and an auto stop time so it shuts down when idle. The editor gives you a catalog browser, autocomplete, multiple result tabs, visualizations, and Genie Code for help writing or fixing SQL.

Example: Karan opens SQL Editor, picks Serverless Starter Warehouse, sets the context to main.sales and runs a query that totals orders by region.

Why we use it

Analysts need fast, concurrent SQL without managing Spark clusters. SQL warehouses are tuned for BI-style queries, scale with users and stop when idle, and the editor gives one place to write, save and share SQL on governed Unity Catalog data.

When to use it

Use a SQL warehouse for ad-hoc SQL, dashboards, Genie and BI tools like Power BI. Use notebooks on general compute for Python, ML or complex Spark jobs. Choose serverless where available; scale up size for slow complex queries and raise max clusters for many concurrent users.

How it works

  1. Open SQL Editor
  2. Pick a SQL warehouse (it starts if stopped)
  3. Set the default catalog and schema, e.g. main.sales
  4. Write the query; use autocomplete and Genie Code for help
  5. Is the query slow? Yes: Check the query profile, then size up or optimize the table. No: Save it and share.
  6. Add a visualization or use it in a dashboard

Syntax

UI: SQL Editor → choose warehouse → set catalog.schema → write query → Run (Ctrl/Cmd + Enter)
UI: SQL Warehouses → Create SQL warehouse → Name, Cluster size, Auto stop, Scaling (min/max), Type
SQL: USE CATALOG main; USE SCHEMA sales;

Example

USE CATALOG main;
USE SCHEMA sales;

SELECT region,
       SUM(amount)   AS total_sales,
       COUNT(*)      AS orders
FROM orders
WHERE order_date >= '2026-10-01'
GROUP BY region
ORDER BY total_sales DESC;

-- Parameterised version for dashboards and reuse
SELECT region, SUM(amount) AS total_sales
FROM main.sales.orders
WHERE order_date BETWEEN :start_date AND :end_date
GROUP BY region;

Key points

Databricks topics

Databricks Fundamentals

Compute

Notebooks & Development

Apache Spark on Databricks

Delta Lake

Unity Catalog & Governance

Data Ingestion

Declarative Pipelines (Lakeflow)

Lakeflow Jobs

Databricks SQL & BI

Architecture, Performance & Cost

Machine Learning & AI

Certification & Interview

T
Tech Town
Log InSign Up Free
Home SQL Python DSA Power BI Snowflake Databricks Spark Gen AI Practice Problems Contest Blog

Master Databricks

The lakehouse platform from the ground up: Apache Spark, Delta Lake, Unity Catalog, Lakeflow pipelines and jobs, Databricks SQL and MLflow. Click any topic in the sidebar to open it right here.

{{ sectionCount }}
Sections
{{ topicCount }}
Topics
Free
Forever
Hands-on practice Practice SQL / Spark SQL Sharpen the SQL you use in Databricks SQL and Spark SQL: 150 query problems in a live editor with instant checking. Start practising →
Section {{ sec.num }}

{{ sec.label }}

Databricks  /  {{ current.sectionLabel }}  /  {{ current.name }}

{{ current.name }}

Theory

{{ current.def }}

Why we use it

{{ rich.why }}

When to use it

{{ rich.when }}

{{ sec.h }}

{{ sec.body }}

{{ sec.body }}

Diagram

{{ rich.dg.caption }}

{{ tb.title }}
{{ c.v }}
{{ rich.dg.op }}
➜
{{ rich.dg.output.title }}
{{ c.v }}
{{ nd.label }}
{{ nd.sub }}
{{ nd.label }}
{{ nd.sub }}
{{ rich.dg.left.title }}
{{ it }}
{{ rich.dg.right.title }}
{{ it }}
On screen — where to click

{{ rich.ui.title }}

{{ u.text }}
  1. {{ st.n }}{{ st.text }}
{{ rich.ui.title }}
{{ u.text }}
Flowchart — how it works
{{ nd.text }}
{{ nd.text }}
◇ {{ nd.text }}
Yes → {{ nd.yes }}
No → {{ nd.no }}
Syntax
{{ current.syntax }}
Example
{{ current.example }}
Want to run this yourself? Databricks needs a real workspace — there's no in-browser engine for it. Click Copy above, then paste it into a notebook or the SQL editor in Databricks Free Edition (free, no credit card) and run it on serverless compute.
Key Points — click to check off as you learn
  • {{ pt.mark }} {{ pt.text }}

Share this topic