cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Database within a Database in Databricks

User16790091296
Contributor II

Is it possible to have a folder or database with a database in Azure Databricks? I know you can use the "create database if not exists xxx" to get a database, but I want to have folders within that database where I can put tables.

2 REPLIES 2

Ryan_Chynoweth
Esteemed Contributor

I think that you are looking to provide a "LOCATION" for your database on DBFS. When you provide a location for your database all the tables will be created within that folder by default.

See a create table example below:

CREATE TABLE [ IF NOT EXISTS ] table_identifier
  [ ( col_name1 col_type1 [ COMMENT col_comment1 ], ... ) ]
  USING data_source
  [ OPTIONS ( key1 [ = ] val1, key2 [ = ] val2, ... ) ]
  [ PARTITIONED BY ( col_name1, col_name2, ... ) ]
  [ CLUSTERED BY ( col_name3, col_name4, ... )
      [ SORTED BY ( col_name [ ASC | DESC ], ... ) ]
      INTO num_buckets BUCKETS ]
  [ LOCATION path ]
  [ COMMENT table_comment ]
  [ TBLPROPERTIES ( key1 [ = ] val1, key2 [ = ] val2, ... ) ]
  [ AS select_statement ]

brickster_2018
Esteemed Contributor

The default location of a database will be in the /user/hive/warehouse/<databasename.db>. Irrespective of the location of the database the tables in the database can have different locations and they can be specified at the time of creation.

Database location and Table location are independent. A table can be created in any location. So to answer your question, it's possible to create a sub-directory and create tables in that.

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group