{"id":762,"date":"2025-08-19T15:24:58","date_gmt":"2025-08-19T15:24:58","guid":{"rendered":"https:\/\/dataopsschool.com\/blog\/?p=762"},"modified":"2025-08-19T16:52:13","modified_gmt":"2025-08-19T16:52:13","slug":"databricks-lab-catalog-with-external-location-storage-credentials-in-unity-catalog","status":"publish","type":"post","link":"https:\/\/dataopsschool.com\/blog\/databricks-lab-catalog-with-external-location-storage-credentials-in-unity-catalog\/","title":{"rendered":"Databricks Lab &#8211; Catalog with External Location, &amp; Storage Credentials in Unity Catalog"},"content":{"rendered":"\n<p>Good Read &#8211; <a href=\"https:\/\/dataopsschool.com\/blog\/databricks-catalog-schemas-tables-with-external-location\/\">https:\/\/dataopsschool.com\/blog\/databricks-catalog-schemas-tables-with-external-location\/<\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\"><\/h1>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1. Create Catalog without External Location<\/strong> <\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go to <strong>Catalog tab<\/strong> in Databricks workspace.<\/li>\n\n\n\n<li>Click <strong>\u201c+ Add Catalog\u201d<\/strong>.<\/li>\n\n\n\n<li>Provide a catalog <strong>name<\/strong> (e.g., <code>Dev<\/code>).<\/li>\n\n\n\n<li>Choose <strong>type = Standard<\/strong>.<\/li>\n\n\n\n<li><strong>Do not<\/strong> specify any external location \u2192 data defaults to <strong>metastore location<\/strong>.<\/li>\n\n\n\n<li>Click <strong>Create<\/strong> \u2192 Catalog is created with default schemas (<code>default<\/code>, <code>information_schema<\/code>).<\/li>\n\n\n\n<li>To check catalog details: <code>DESCRIBE CATALOG EXTENDED Dev;<\/code> (Shows no location specified \u2192 fallback to metastore storage.)<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. Create Catalog with SQL<\/strong> <\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Open a <strong>SQL notebook<\/strong> in Databricks.<\/li>\n\n\n\n<li>Ensure cluster is <strong>Unity Catalog enabled<\/strong>.<\/li>\n\n\n\n<li>Run SQL command: <code>CREATE CATALOG DevSQL COMMENT \"This catalog is created using SQL\";<\/code><\/li>\n\n\n\n<li>Verify with: <code>DESCRIBE CATALOG EXTENDED DevSQL;<\/code><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. Drop Catalog and Drop Catalog Recursively<\/strong> <\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>To drop a catalog: <code>DROP CATALOG DevSQL;<\/code> \u274c Error \u2192 cannot drop because it contains schemas\/tables.<\/li>\n\n\n\n<li>Use <strong>CASCADE<\/strong> to drop everything inside recursively: <code>DROP CATALOG DevSQL CASCADE;<\/code> \u2705 Removes catalog + schemas + tables.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>4. Create External Location in Databricks<\/strong> <\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go to <strong>Catalog &gt; External Data &gt; Create Location<\/strong>.<\/li>\n\n\n\n<li>Or via SQL: <code>CREATE EXTERNAL LOCATION `ext_catalogs` URL 'abfss:\/\/data@&lt;storage_account&gt;.dfs.core.windows.net\/ADB\/catalog\/' WITH STORAGE CREDENTIAL `SC_catalog_storage`;<\/code><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>5. Create Storage Credential in Databricks<\/strong> <\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Navigate to <strong>Catalog &gt; Storage Credentials &gt; Create Credential<\/strong>.<\/li>\n\n\n\n<li>Choose <strong>Azure Managed Identity<\/strong>.<\/li>\n\n\n\n<li>Provide credential name (e.g., <code>SC_catalog_storage<\/code>).<\/li>\n\n\n\n<li>Supply <strong>UC connector Resource ID<\/strong> (from Azure portal).<\/li>\n\n\n\n<li>Click <strong>Create<\/strong> \u2192 Storage credential created.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>6. Create Catalog with External Location<\/strong> <\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Run SQL to create a catalog with managed location: <\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>CREATE CATALOG DevEXT\nMANAGED LOCATION 'abfss:\/\/data@&lt;storage_account&gt;.dfs.core.windows.net\/ADB\/catalog\/'\nCOMMENT \"Catalog with external location\";\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><\/li>\n\n\n\n<li>Verify: <\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>DESCRIBE CATALOG EXTENDED DevEXT;\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">Final Flow Summary<\/h1>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create Catalog without external location \u2192 defaults to metastore.<\/li>\n\n\n\n<li>Create Catalog using SQL.<\/li>\n\n\n\n<li>Drop catalog normally or recursively with <strong>CASCADE<\/strong>.<\/li>\n\n\n\n<li>Create External Location in Databricks.<\/li>\n\n\n\n<li>Create Storage Credential for external storage.<\/li>\n\n\n\n<li>Create Catalog with External Location bound to that credential.<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Let\u2019s build a <strong>practical example<\/strong> using your catalog <code>dev_ext<\/code>.<br>I\u2019ll show you:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create a <strong>schema<\/strong> inside the catalog.<\/li>\n\n\n\n<li>Create a <strong>table<\/strong> in that schema.<\/li>\n\n\n\n<li>Insert sample data.<\/li>\n\n\n\n<li>Query the data back.<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">1\ufe0f\u20e3 Create a Schema in <code>dev_ext<\/code><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>-- Create a schema called bronze inside catalog dev_ext\nCREATE SCHEMA IF NOT EXISTS dev_ext.bronze\nCOMMENT 'Bronze schema for raw ingested data in dev_ext catalog';\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">2\ufe0f\u20e3 Create a Managed Table in the Schema<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>-- Create a managed table (no LOCATION clause \u2192 stored at catalog\/schema location)\nCREATE TABLE IF NOT EXISTS dev_ext.bronze.sales_data (\n  id INT,\n  product STRING,\n  amount DOUBLE,\n  sale_date DATE\n)\nCOMMENT 'Sales transactions table';\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">3\ufe0f\u20e3 Insert Some Sample Data<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>INSERT INTO dev_ext.bronze.sales_data VALUES\n  (1, 'Laptop', 1200.50, DATE'2025-08-01'),\n  (2, 'Phone', 750.00, DATE'2025-08-05'),\n  (3, 'Tablet', 500.00, DATE'2025-08-10'),\n  (4, 'Headphones', 120.00, DATE'2025-08-12');\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">4\ufe0f\u20e3 Query the Data<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT * \nFROM dev_ext.bronze.sales_data;\n<\/code><\/pre>\n\n\n\n<p>\u2705 You\u2019ll see the four rows returned.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The data files will be stored in the <strong>catalog-level managed location<\/strong> (since you didn\u2019t set schema\/table <code>LOCATION<\/code>).<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Good Read &#8211; https:\/\/dataopsschool.com\/blog\/databricks-catalog-schemas-tables-with-external-location\/ 1. Create Catalog without External Location 2. Create Catalog with SQL 3. Drop Catalog and Drop Catalog Recursively 4. Create External Location in&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-762","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/dataopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/762","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dataopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dataopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dataopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dataopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=762"}],"version-history":[{"count":3,"href":"https:\/\/dataopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/762\/revisions"}],"predecessor-version":[{"id":780,"href":"https:\/\/dataopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/762\/revisions\/780"}],"wp:attachment":[{"href":"https:\/\/dataopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=762"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dataopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=762"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dataopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=762"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}