Member-only story
Databricks Notebook Magic Commands: Beyond %sql and %python
The built-in commands everyone should know, the IPython extras worth trying, and the Databricks utilities that fill the gaps.
Most people working with Databricks notebooks learn %sql, %python, and %run during their first week and rarely look beyond them. But notebook cells can do more than run SQL queries or Python scripts. With a few extra commands, you can time code, capture output, run shell commands, inspect variables, and look up documentation without leaving the notebook.
This guide covers two groups of commands, and the distinction is important when something doesn’t work as expected. The first group consists of documented Databricks features. The second consists of IPython magics inherited from the notebook’s underlying Python environment.
Both can be useful, but they aren’t interchangeable. IPython magic commands may behave differently depending on your Databricks Runtime version and compute type. Before relying on them in a shared workflow, test them on the cluster where you intend to use them.
1. How magic commands work
A magic command is a special instruction that starts with % and changes how a notebook cell behaves. It lets you do things that go beyond running ordinary code.











