CREATE VOLUME

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime 13.3 LTS and above check marked yes Unity Catalog only

Creates a volume with the specified name. If a volume with the same name already exists in the schema SCHEMA_NOT_FOUND is raised.

See Volumes for details about using volumes.

Syntax

CREATE [ EXTERNAL ] VOLUME [ IF NOT EXISTS ] volume_name
    [ LOCATION location_path ]
    [ COMMENT comment ]

Parameters

  • EXTERNAL

    Creates an external volume. If EXTERNAL is not specified the statement creates a managed volume.

  • IF NOT EXISTS

    Creates a volume with the given name if it does not exist. If a volume with the same name already exists, nothing will happen.

  • volume_name

    The name of the volume to be created. Volumes can only be created in Unity Catalog schemas.

  • LOCATION location_path

    location_path is a STRING literal defining the path of the file system in which the specified external volume is created. If the specified path does not exist in the underlying file system, creates a directory with the path. The chosen path should not overlap with the location of any other volumes or tables.

  • This clause does not apply for managed volumes.

  • comment

    An optional STRING literal description for the volume.

Examples


-- Create an external volume on the specified location with comment
> CREATE EXTERNAL VOLUME my_catalog.my_schema.my_external_volume
    LOCATION 's3://my-bucket/my-location/my-path'
    COMMENT 'This is my example external volume on S3'
  OK

-- Query the data from the file in the created volume
> SELECT *
    FROM csv.`/Volumes/my_catalog/my_schema/my_external_volume/foo.csv`

-- Create a managed volume with full schema name
> CREATE VOLUME my_catalog.my_schema.my_volume
  OK

-- Create a managed volume in default catalog and schema
> CREATE VOLUME my_another_volume
  OK