Share via

Getting error while creating database

Ramanathan Murugan Veerabagu 0 Reputation points
2025-02-13T04:09:46.5566667+00:00
In Azure Databricks, I'm getting error while creating Database with the following syntax : -

CREATE DATABASE IF NOT EXISTS <DB_Name>
LOCATION "/mnt/<Container_Name>/<Folder_Name>"

error is 1
"CREATE SCHEMA in Unity Catalog must use MANAGED LOCATION, not LOCATION"
I tried prefixing Managed, I'm getting error too.
Please advise

Note: It got executed without any errors yesterday (in a different Notebook), when I try to re run this notebook, its getting executed without any error.
 I tried with a new notebook, I'm getting the above error. 
Both the notebooks are in the same folder (under workspace) and connected to same cluster
Azure Databricks
Azure Databricks

An Apache Spark-based analytics platform optimized for Azure.


1 answer

Sort by: Most helpful
  1. Smaran Thoomu 35,125 Reputation points Microsoft External Staff Moderator
    2025-02-13T13:18:53.43+00:00

    Hi @Ramanathan Murugan Veerabagu
    It looks like you're running into a Unity Catalog restriction. In Unity Catalog, CREATE SCHEMA (or CREATE DATABASE) must use a MANAGED LOCATION instead of a custom LOCATION.

    Here’s what you can try:

    1. Check if your metastore has a managed location set – You can only create schemas in Unity Catalog with a managed location.
    2. Use MANAGED LOCATION instead of LOCATION – The correct syntax should be:
         CREATE DATABASE IF NOT EXISTS <DB_Name>  
         MANAGED LOCATION "abfss://<container>@<storage_account>.dfs.core.windows.net/<path>/"
      
    3. Confirm your cluster is using Unity Catalog – If it worked in one notebook but not another, check if the cluster is configured for Unity Catalog.

    Since it worked yesterday but not today, there might have been a change in your workspace setup. You can also try running SHOW DATABASES to check if the database exists in Unity Catalog.

    Let me know if this helps!

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.